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.

130 lines
6.0 KiB

  1. /*
  2. * Filename: NLB_XMLDocument.h
  3. * Description:
  4. * Author: shouse, 04.10.01
  5. */
  6. #ifndef __NLB_XMLDOCUMENT_H__
  7. #define __NLB_XMLDOCUMENT_H__
  8. #include <windows.h>
  9. #include "NLB_Common.h"
  10. #include "NLB_Cluster.h"
  11. #include "NLB_Host.h"
  12. #include "NLB_PortRule.h"
  13. typedef struct _NLB_XMLError {
  14. LONG code;
  15. LONG line;
  16. LONG character;
  17. WCHAR wszURL[MAX_PATH];
  18. WCHAR wszReason[MAX_PATH];
  19. } NLB_XMLError;
  20. #define FACILITY_NLB 49
  21. #define NLB_ERROR_CLUSTER_NAME_MISSING 1
  22. #define NLB_DESCR_CLUSTER_NAME_MISSING L"The required cluster attribute \"Name\" was not found."
  23. class NLB_XMLDocument {
  24. public:
  25. NLB_XMLDocument ();
  26. NLB_XMLDocument (bool bSilent);
  27. ~NLB_XMLDocument ();
  28. HRESULT Validate (const WCHAR * wszFileName);
  29. HRESULT Parse (const WCHAR * wszFileName, vector<NLB_Cluster> & Clusters);
  30. HRESULT Save (const WCHAR * wszFileName, vector<NLB_Cluster> Clusters);
  31. void Print (vector<NLB_Cluster> Clusters);
  32. void GetParseError (NLB_XMLError & Error);
  33. private:
  34. BSTR AsciiToBSTR (const char * pszName);
  35. CHAR * BSTRToAscii (const WCHAR * pwszName);
  36. NLB_ClusterMode::NLB_ClusterModeType StringToClusterMode (const PWCHAR pwszType);
  37. PWCHAR ClusterModeToString (const NLB_ClusterMode::NLB_ClusterModeType Type);
  38. NLB_HostState::NLB_HostStateType StringToHostState (const PWCHAR pwszType);
  39. PWCHAR HostStateToString (const NLB_HostState::NLB_HostStateType Type);
  40. NLB_PortRuleState::NLB_PortRuleStateType StringToPortRuleState (const PWCHAR pwszType);
  41. PWCHAR PortRuleStateToString (const NLB_PortRuleState::NLB_PortRuleStateType Type);
  42. NLB_PortRuleProtocol::NLB_PortRuleProtocolType StringToPortRuleProtocol (const PWCHAR pwszType);
  43. PWCHAR PortRuleProtocolToString (const NLB_PortRuleProtocol::NLB_PortRuleProtocolType Type);
  44. NLB_PortRuleFilteringMode::NLB_PortRuleFilteringModeType StringToPortRuleFilteringMode (const PWCHAR pwszType);
  45. PWCHAR PortRuleFilteringModeToString (const NLB_PortRuleFilteringMode::NLB_PortRuleFilteringModeType Type);
  46. NLB_PortRuleAffinity::NLB_PortRuleAffinityType StringToPortRuleAffinity (const PWCHAR pwszType);
  47. PWCHAR PortRuleAffinityToString (const NLB_PortRuleAffinity::NLB_PortRuleAffinityType Type);
  48. HRESULT LoadDocument (BSTR pBURL);
  49. HRESULT CheckDocumentLoad ();
  50. HRESULT BeautifyDocument (MSXML2::IXMLDOMNode * pNode, ULONG depth);
  51. HRESULT InsertFormatting (PWCHAR Text, MSXML2::IXMLDOMNode * pUnder, MSXML2::IXMLDOMNode * pBefore);
  52. void SetParseError (HRESULT hrCode, PWSTR pwszReason);
  53. HRESULT ParseCluster (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  54. HRESULT ParseClusterProperties (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  55. HRESULT ParseIPAddress (MSXML2::IXMLDOMNode * pNode, NLB_IPAddress * pIPAddress);
  56. HRESULT ParseAdapter (MSXML2::IXMLDOMNode * pNode, NLB_Adapter * pAdapter);
  57. HRESULT ParseRemoteControl (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  58. HRESULT ParseHostState (MSXML2::IXMLDOMNode * pNode, NLB_Host * pHost);
  59. HRESULT ParseBidirectionalAffinity (MSXML2::IXMLDOMNode * pNode, NLB_ClusterBDASupport * pBDA);
  60. HRESULT ParseClusterHosts (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  61. HRESULT ParseClusterPortRules (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  62. HRESULT ParseHost (MSXML2::IXMLDOMNode * pNode, NLB_Host * pHost);
  63. HRESULT ParsePortRule (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  64. HRESULT ParseFiltering (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  65. HRESULT ParsePriorities (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  66. HRESULT ParseLoadWeights (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  67. HRESULT SaveCluster (MSXML2::IXMLDOMNode * pRoot, NLB_Cluster * pCluster);
  68. HRESULT SaveClusterProperties (MSXML2::IXMLDOMNode * pRoot, NLB_Cluster * pCluster);
  69. HRESULT SaveIPAddress (MSXML2::IXMLDOMNode * pRoot, NLB_IPAddress * pAddress);
  70. HRESULT SaveAdapter (MSXML2::IXMLDOMNode * pRoot, NLB_Adapter * pAdapter);
  71. HRESULT SaveRemoteControl (MSXML2::IXMLDOMNode * pRoot, NLB_Cluster * pCluster);
  72. HRESULT SaveHostState (MSXML2::IXMLDOMNode * pNode, NLB_Host * pHost);
  73. HRESULT SaveBidirectionalAffinity (MSXML2::IXMLDOMNode * pNode, NLB_ClusterBDASupport * pBDA);
  74. HRESULT SaveClusterHosts (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  75. HRESULT SaveClusterPortRules (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  76. HRESULT SaveHost (MSXML2::IXMLDOMNode * pNode, NLB_Host * pHost);
  77. HRESULT SavePortRule (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  78. HRESULT SaveFiltering (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  79. HRESULT SavePriorities (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  80. HRESULT SaveLoadWeights (MSXML2::IXMLDOMNode * pNode, NLB_PortRule * pRule);
  81. MSXML2::IXMLDOMNode * CreateNode(MSXML2::IXMLDOMDocument* pDoc, int type, PWCHAR pName);
  82. MSXML2::IXMLDOMNode * CreateNode(MSXML2::IXMLDOMDocument* pDoc, int type, PWCHAR pName, PWCHAR pValue);
  83. HRESULT SetIntegerAttribute(MSXML2::IXMLDOMNode * pNode, PWCHAR pAttribute, ULONG value);
  84. HRESULT GetIntegerAttribute(MSXML2::IXMLDOMNode * pNode, PWCHAR pAttribute, PULONG value);
  85. HRESULT SetBooleanAttribute(MSXML2::IXMLDOMNode * pNode, PWCHAR pAttribute, bool value);
  86. HRESULT GetBooleanAttribute(MSXML2::IXMLDOMNode * pNode, PWCHAR pAttribute, bool * value);
  87. HRESULT SetStringAttribute(MSXML2::IXMLDOMNode * pNode, PWCHAR pAttribute, PWCHAR pValue);
  88. HRESULT GetStringAttribute(MSXML2::IXMLDOMNode * pNode, PWCHAR pAttribute, PWCHAR pValue, ULONG length);
  89. HRESULT SetNodeValue(MSXML2::IXMLDOMNode * pNode, PWCHAR value);
  90. HRESULT GetNodeValue(MSXML2::IXMLDOMNode * pNode, PWCHAR value, ULONG length);
  91. private:
  92. MSXML2::IXMLDOMDocument2 * pDoc;
  93. MSXML2::IXMLDOMSchemaCollection * pSchema;
  94. NLB_XMLError ParseError;
  95. bool bShowErrorPopups;
  96. };
  97. #endif