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.

360 lines
11 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1998-2000 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: schemaMisc.h
  6. //
  7. // Author: Charles Ma
  8. // 2000.12.4
  9. //
  10. // Description:
  11. //
  12. // header file of helper functions for IU schemas
  13. //
  14. //=======================================================================
  15. #pragma once
  16. #include <msxml.h>
  17. //
  18. // max length of platform when being converted into string
  19. // this is an artificial number that we think enough to
  20. // take any MS platform data.
  21. //
  22. extern const UINT MAX_PLATFORM_STR_LEN; // = 1024
  23. //
  24. // private flags used by functions to retrieve string data
  25. //
  26. extern const DWORD SKIP_SUITES; //= 0x1;
  27. extern const DWORD SKIP_SERVICEPACK_VER; //= 0x2;
  28. /////////////////////////////////////////////////////////////////////////////
  29. //
  30. // Helper function DoesNodeHaveName()
  31. //
  32. // find out the the current node has a matching name
  33. //
  34. // Input:
  35. // a node
  36. //
  37. // Return:
  38. // TRUE/FALSE
  39. //
  40. /////////////////////////////////////////////////////////////////////////////
  41. BOOL DoesNodeHaveName(
  42. IXMLDOMNode* pNode,
  43. BSTR bstrTagName
  44. );
  45. //----------------------------------------------------------------------
  46. //
  47. // Helper function FindNode()
  48. // retrieve the named child node
  49. //
  50. // Input:
  51. // an IXMLDomNode and a bstr name
  52. //
  53. // Return:
  54. // BOOL, tells succeed or not
  55. //
  56. // Assumption:
  57. // input parameter not NULL
  58. // in case of fail, variant not touched
  59. //
  60. //----------------------------------------------------------------------
  61. BOOL
  62. FindNode(
  63. IXMLDOMNode* pCurrentNode,
  64. BSTR bstrName,
  65. IXMLDOMNode** ppFoundNode
  66. );
  67. //----------------------------------------------------------------------
  68. //
  69. // Helper function FindNodeValue()
  70. // retrieve the text data from a named child of the current node,
  71. //
  72. // Input:
  73. // an IXMLDomNode
  74. //
  75. // Return:
  76. // BOOL, tells succeed or not
  77. //
  78. // Assumption:
  79. // input parameter not NULL
  80. // in case of fail, variant not touched
  81. //
  82. //----------------------------------------------------------------------
  83. BOOL
  84. FindNodeValue(
  85. IXMLDOMNode* pCurrentNode,
  86. BSTR bstrName,
  87. BSTR* pbstrValue);
  88. /////////////////////////////////////////////////////////////////////////////
  89. // ReportParseError()
  90. //
  91. // Report parsing error information
  92. /////////////////////////////////////////////////////////////////////////////
  93. HRESULT ReportParseError(IXMLDOMParseError *pXMLError);
  94. /////////////////////////////////////////////////////////////////////////////
  95. // ValidateDoc()
  96. //
  97. // Validate the xml doc against the schema
  98. /////////////////////////////////////////////////////////////////////////////
  99. HRESULT ValidateDoc(IXMLDOMDocument* pDoc);
  100. /////////////////////////////////////////////////////////////////////////////
  101. // FindSingleDOMNode()
  102. //
  103. // Retrieve the first xml node with the given tag name under the given parent node
  104. /////////////////////////////////////////////////////////////////////////////
  105. HRESULT FindSingleDOMNode(IXMLDOMNode* pParentNode, BSTR bstrName, IXMLDOMNode** ppNode);
  106. /////////////////////////////////////////////////////////////////////////////
  107. // FindSingleDOMNode()
  108. //
  109. // Retrieve the first xml node with the given tag name in the given xml doc
  110. /////////////////////////////////////////////////////////////////////////////
  111. HRESULT FindSingleDOMNode(IXMLDOMDocument* pDoc, BSTR bstrName, IXMLDOMNode** ppNode);
  112. /////////////////////////////////////////////////////////////////////////////
  113. // FindDOMNodeList()
  114. //
  115. // Retrieve the xml nodelist with the given tag name under the given parent node
  116. /////////////////////////////////////////////////////////////////////////////
  117. IXMLDOMNodeList* FindDOMNodeList(IXMLDOMNode* pParentNode, BSTR bstrName);
  118. /////////////////////////////////////////////////////////////////////////////
  119. // FindDOMNodeList()
  120. //
  121. // Retrieve the xml nodelist with the given tag name in the given xml doc
  122. /////////////////////////////////////////////////////////////////////////////
  123. IXMLDOMNodeList* FindDOMNodeList(IXMLDOMDocument* pDoc, BSTR bstrName);
  124. /////////////////////////////////////////////////////////////////////////////
  125. // CreateDOMNode()
  126. //
  127. // Create an xml node of the given type
  128. /////////////////////////////////////////////////////////////////////////////
  129. IXMLDOMNode* CreateDOMNode(IXMLDOMDocument* pDoc, SHORT nType, BSTR bstrName, BSTR bstrNamespaceURI = NULL);
  130. /////////////////////////////////////////////////////////////////////////////
  131. // GetAttribute()
  132. //
  133. // In various flavors.
  134. /////////////////////////////////////////////////////////////////////////////
  135. HRESULT GetAttribute(IXMLDOMNode* pNode, BSTR bstrName, INT* piAttr);
  136. HRESULT GetAttributeBOOL(IXMLDOMNode* pNode, BSTR bstrName, BOOL* pfAttr);
  137. HRESULT GetAttribute(IXMLDOMNode* pNode, BSTR bstrName, LONG* piAttr);
  138. HRESULT GetAttribute(IXMLDOMNode* pNode, BSTR bstrName, BSTR* pbstrAttr);
  139. /////////////////////////////////////////////////////////////////////////////
  140. // SetAttribute()
  141. //
  142. // Set attribute (integer) to the xml element
  143. /////////////////////////////////////////////////////////////////////////////
  144. HRESULT SetAttribute(IXMLDOMNode* pNode, BSTR bstrName, INT iAttr);
  145. /////////////////////////////////////////////////////////////////////////////
  146. // SetAttribute()
  147. //
  148. // Set attribute (BSTR) to the xml element
  149. /////////////////////////////////////////////////////////////////////////////
  150. HRESULT SetAttribute(IXMLDOMNode* pNode, BSTR bstrName, BSTR bstrAttr);
  151. /////////////////////////////////////////////////////////////////////////////
  152. // SetAttribute()
  153. //
  154. // Set attribute (VARIANT) to the xml element
  155. /////////////////////////////////////////////////////////////////////////////
  156. HRESULT SetAttribute(IXMLDOMNode* pNode, BSTR bstrName, VARIANT vAttr);
  157. /////////////////////////////////////////////////////////////////////////////
  158. // GetText()
  159. //
  160. // Get text (BSTR) from the xml node
  161. /////////////////////////////////////////////////////////////////////////////
  162. HRESULT GetText(IXMLDOMNode* pNode, BSTR* pbstrText);
  163. /////////////////////////////////////////////////////////////////////////////
  164. // SetValue()
  165. //
  166. // Set value (integer) for the xml node
  167. /////////////////////////////////////////////////////////////////////////////
  168. HRESULT SetValue(IXMLDOMNode* pNode, INT iValue);
  169. /////////////////////////////////////////////////////////////////////////////
  170. // SetValue()
  171. //
  172. // Set value (BSTR) for the xml node
  173. /////////////////////////////////////////////////////////////////////////////
  174. HRESULT SetValue(IXMLDOMNode* pNode, BSTR bstrValue);
  175. /////////////////////////////////////////////////////////////////////////////
  176. // InsertNode()
  177. //
  178. // Insert a child node to the parent node
  179. /////////////////////////////////////////////////////////////////////////////
  180. HRESULT InsertNode(IXMLDOMNode* pParentNode, IXMLDOMNode* pChildNode, IXMLDOMNode* pChildNodeRef = NULL);
  181. /////////////////////////////////////////////////////////////////////////////
  182. // CopyNode()
  183. //
  184. // Create an xml node as a copy of the given node;
  185. // this is different from cloneNode() as it copies node across xml document
  186. /////////////////////////////////////////////////////////////////////////////
  187. HRESULT CopyNode(IXMLDOMNode* pNodeSrc, IXMLDOMDocument* pDocDes, IXMLDOMNode** ppNodeDes);
  188. /////////////////////////////////////////////////////////////////////////////
  189. // AreNodesEqual()
  190. //
  191. // Return TRUE if two nodes are identical, return FALSE if they're different.
  192. /////////////////////////////////////////////////////////////////////////////
  193. BOOL AreNodesEqual(IXMLDOMNode* pNode1, IXMLDOMNode* pNode2);
  194. /////////////////////////////////////////////////////////////////////////////
  195. // LoadXMLDoc()
  196. //
  197. // Load an XML Document from string
  198. /////////////////////////////////////////////////////////////////////////////
  199. HRESULT LoadXMLDoc(BSTR bstrXml, IXMLDOMDocument** ppDoc, BOOL fOffline = TRUE);
  200. /////////////////////////////////////////////////////////////////////////////
  201. // LoadDocument()
  202. //
  203. // Load an XML Document from the specified file
  204. /////////////////////////////////////////////////////////////////////////////
  205. HRESULT LoadDocument(BSTR bstrFilePath, IXMLDOMDocument** ppDoc, BOOL fOffline = TRUE);
  206. /////////////////////////////////////////////////////////////////////////////
  207. // SaveDocument()
  208. //
  209. // Save an XML Document to the specified location
  210. /////////////////////////////////////////////////////////////////////////////
  211. HRESULT SaveDocument(IXMLDOMDocument* pDoc, BSTR bstrFilePath);
  212. //----------------------------------------------------------------------
  213. //
  214. // public function Get3IdentiStrFromIdentNode()
  215. // retrieve the name, publisherName and GUID from an identity node
  216. //
  217. // Return:
  218. // HREUSLT - error code
  219. //
  220. //----------------------------------------------------------------------
  221. HRESULT
  222. Get3IdentiStrFromIdentNode(
  223. IXMLDOMNode* pIdentityNode,
  224. BSTR* pbstrName,
  225. BSTR* pbstrPublisherName,
  226. BSTR* pbstrGUID
  227. );
  228. //----------------------------------------------------------------------
  229. //
  230. // public function UtilGetUniqIdentityStr()
  231. // retrieve the unique string that make this <identity> node unique
  232. //
  233. // Return:
  234. // HREUSLT - error code
  235. //
  236. //----------------------------------------------------------------------
  237. HRESULT
  238. UtilGetUniqIdentityStr(
  239. IXMLDOMNode* pIdentityNode,
  240. BSTR* pbstrUniqIdentifierString,
  241. DWORD dwFlag);
  242. //----------------------------------------------------------------------
  243. //
  244. // public function UtilGetPlatformStr()
  245. // retrieve the unique string that make this <platform> node unique
  246. //
  247. // Return:
  248. // HREUSLT - error code
  249. //
  250. //----------------------------------------------------------------------
  251. HRESULT
  252. UtilGetPlatformStr(
  253. IXMLDOMNode* pNodePlatform,
  254. BSTR* pbstrPlatform,
  255. DWORD dwFlag);
  256. //----------------------------------------------------------------------
  257. //
  258. // public function UtilGetVersionStr()
  259. // retrieve the data from this <version> in string format
  260. //
  261. // Return:
  262. // HREUSLT - error code
  263. //
  264. //----------------------------------------------------------------------
  265. HRESULT
  266. UtilGetVersionStr(
  267. IXMLDOMNode* pVersionNode,
  268. LPTSTR pszVersion,
  269. DWORD dwFlag);
  270. /////////////////////////////////////////////////////////////////////////////
  271. // MakeUniqNameString()
  272. //
  273. // This is a utility function to construct the identity name string
  274. // based on name|publiser|GUID and the rule to make this name string.
  275. //
  276. // This function defines the logic about what components can be used
  277. // to define the uniqueness of an item based on the 3 parts of data from
  278. // GetIdentity().
  279. //
  280. /////////////////////////////////////////////////////////////////////////////
  281. HRESULT MakeUniqNameString(
  282. BSTR bstrName,
  283. BSTR bstrPublisher,
  284. BSTR bstrGUID,
  285. BSTR* pbstrUniqIdentifierString);
  286. //-----------------------------------------------------------------------
  287. //
  288. // function GetFullFilePathFromFilePathNode()
  289. //
  290. // retrieve the full qualified file path from a filePath node
  291. // the path retrieved is expanded.
  292. //
  293. // Input:
  294. // a filePath XMLDom node
  295. // a pointer to a buffer to receive path, assumes MAX_PATH long.
  296. //
  297. // Return:
  298. // HRESULT
  299. //
  300. //
  301. //-----------------------------------------------------------------------
  302. HRESULT GetFullFilePathFromFilePathNode(
  303. IXMLDOMNode* pFilePathNode,
  304. LPTSTR lpszFilePath
  305. );
  306. HRESULT GetBstrFullFilePathFromFilePathNode(
  307. IXMLDOMNode* pFilePathNode,
  308. BSTR* pbstrFilePath
  309. );