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.

290 lines
5.7 KiB

  1. //
  2. // global.h
  3. //
  4. #pragma once
  5. #include "stdafx.h"
  6. #include "SSRTE.h"
  7. #include "ssrmsg.h"
  8. #include <map>
  9. #include <vector>
  10. #include "msxml2.h"
  11. class CFBLogMgr;
  12. extern CFBLogMgr g_fblog;
  13. using namespace std;
  14. const ULONG g_ulSsrEngineMajorVersion = 1;
  15. const ULONG g_ulSsrEngineMinorVersion = 0;
  16. const LONG g_lActionVerbConfigure = 1;
  17. const LONG g_lActionVerbRollback = 2;
  18. const LONG g_lActionVerbReport = 3;
  19. const DWORD g_dwHexDwordLen = 11;
  20. const DWORD g_dwResNothing = 0;
  21. extern WCHAR g_wszSsrRoot[];
  22. extern DWORD g_dwSsrRootLen;
  23. extern LPCWSTR g_pwszSSRRegRoot;
  24. extern LPCWSTR g_pwszSSRMembersReg;
  25. extern LPCWSTR g_pwszSSRRootToExpand;
  26. extern LPCWSTR g_pwszSSR;
  27. extern LPCWSTR g_pwszLogs;
  28. //
  29. // The following are reserved action verbs
  30. //
  31. extern CComBSTR g_bstrConfigure;
  32. extern CComBSTR g_bstrRollback;
  33. extern CComBSTR g_bstrReport;
  34. //
  35. // the following are reserved file-usage values
  36. //
  37. extern CComBSTR g_bstrLaunch;
  38. extern CComBSTR g_bstrResult;
  39. //
  40. // the following is the reserved action data's names
  41. //
  42. extern LPCWSTR g_pwszCurrSecurityPolicy;
  43. extern LPCWSTR g_pwszTransformFiles;
  44. extern LPCWSTR g_pwszScriptFiles;
  45. //
  46. // the following are element tag names
  47. //
  48. extern CComBSTR g_bstrSsrMemberInfo;
  49. extern CComBSTR g_bstrDescription;
  50. extern CComBSTR g_bstrSupportedAction;
  51. extern CComBSTR g_bstrProcedures;
  52. extern CComBSTR g_bstrDefaultProc;
  53. extern CComBSTR g_bstrCustomProc;
  54. extern CComBSTR g_bstrTransformInfo;
  55. extern CComBSTR g_bstrScriptInfo;
  56. //
  57. // the following are attribute names
  58. //
  59. extern CComBSTR g_bstrAttrUniqueName;
  60. extern CComBSTR g_bstrAttrMajorVersion;
  61. extern CComBSTR g_bstrAttrMinorVersion;
  62. extern CComBSTR g_bstrAttrProgID;
  63. extern CComBSTR g_bstrAttrActionName;
  64. extern CComBSTR g_bstrAttrActionType;
  65. extern CComBSTR g_bstrAttrTemplateFile;
  66. extern CComBSTR g_bstrAttrResultFile;
  67. extern CComBSTR g_bstrAttrScriptFile;
  68. extern CComBSTR g_bstrAttrIsStatic;
  69. extern CComBSTR g_bstrAttrIsExecutable;
  70. extern CComBSTR g_bstrReportFilesDir;
  71. extern CComBSTR g_bstrConfigureFilesDir;
  72. extern CComBSTR g_bstrRollbackFilesDir;
  73. extern CComBSTR g_bstrTransformFilesDir;
  74. extern CComBSTR g_bstrMemberFilesDir;
  75. extern CComBSTR g_bstrTrue;
  76. extern CComBSTR g_bstrFalse;
  77. //
  78. // these are the known action types
  79. //
  80. extern LPCWSTR g_pwszApply;
  81. extern LPCWSTR g_pwszPrepare;
  82. typedef LONG SsrActionVerb;
  83. const SsrActionVerb ActionInvalid = 0;
  84. const SsrActionVerb ActionConfigure = 1;
  85. const SsrActionVerb ActionRollback = 2;
  86. const SsrActionVerb ActionReport = 3;
  87. const BSTR SsrPGetActionVerbString (
  88. IN SsrActionVerb action
  89. );
  90. SsrActionVerb SsrPGetActionVerbFromString (
  91. IN LPCWSTR pwszVerb
  92. );
  93. class CMemberAD;
  94. class CActionType
  95. {
  96. public:
  97. CActionType (
  98. IN SsrActionVerb lAction,
  99. IN LONG lActionType
  100. ) : m_lAction(lAction), m_lType(lActionType)
  101. {
  102. }
  103. CActionType (
  104. const CActionType & at
  105. )
  106. : m_lAction(at.m_lAction), m_lType(at.m_lType)
  107. {
  108. }
  109. ~CActionType(){}
  110. SsrActionVerb GetAction()const
  111. {
  112. return m_lAction;
  113. }
  114. LONG GetActionType()const
  115. {
  116. return m_lType;
  117. }
  118. protected:
  119. //
  120. // we don't want anyone (include self) to be able to do an assignment.
  121. //
  122. void operator = (const CActionType& );
  123. SsrActionVerb m_lAction;
  124. LONG m_lType;
  125. };
  126. //
  127. // some global helper functions
  128. //
  129. //template< class T>
  130. template< class T>
  131. class strLessThan
  132. {
  133. public:
  134. bool operator()( const T& X, const T& Y ) const
  135. {
  136. return ( _wcsicmp( X, Y ) < 0 );
  137. }
  138. };
  139. //template<> class strLessThan<BSTR>{};
  140. //template< class T>
  141. template< class T>
  142. class ActionTypeLessThan
  143. {
  144. public:
  145. bool operator()( const T& X, const T& Y ) const
  146. {
  147. if (X.GetAction() < Y.GetAction())
  148. {
  149. return true;
  150. }
  151. else if (X.GetAction() == Y.GetAction())
  152. {
  153. return X.GetActionType() < Y.GetActionType();
  154. }
  155. return false;
  156. }
  157. };
  158. //template<> class ActionTypeLessThan< CActionType >{};
  159. typedef map<BSTR, VARIANT*, strLessThan<BSTR> > MapNameValue;
  160. //typedef MapNameValue::iterator NameValueIterator;
  161. typedef map< const CActionType, CMemberAD*, ActionTypeLessThan< CActionType > > MapMemberAD;
  162. //typedef MapMemberAD::iterator MemberADIterator;
  163. class CSsrMemberAccess;
  164. typedef map<const BSTR, CSsrMemberAccess*, strLessThan<BSTR> > MapMemberAccess;
  165. //typedef MapMemberAccess::iterator MemberAccessIterator;
  166. HRESULT
  167. SsrPDeleteEntireDirectory (
  168. IN LPCWSTR pwszDirPath
  169. );
  170. HRESULT
  171. SsrPCreateSubDirectories (
  172. IN OUT LPWSTR pwszPath,
  173. IN LPCWSTR pwszSubRoot
  174. );
  175. HRESULT SsrPLoadDOM (
  176. IN BSTR bstrFile, // [in],
  177. IN LONG lFlag, // [in],
  178. IN IXMLDOMDocument2 * pDOM // [in]
  179. );
  180. HRESULT SsrPGetBSTRAttrValue (
  181. IN IXMLDOMNamedNodeMap * pNodeMap,
  182. IN BSTR bstrName,
  183. OUT BSTR * pbstrValue
  184. );
  185. HRESULT SsrPCreateUniqueTempDirectory (
  186. OUT LPWSTR pwszTempDirPath,
  187. IN DWORD dwBufLen
  188. );
  189. //
  190. // move files from one location to another
  191. //
  192. HRESULT SsrPMoveFiles (
  193. IN LPCWSTR pwszSrcDirRoot,
  194. IN LPCWSTR pwszDesDirRoot,
  195. IN LPCWSTR pwszRelPath
  196. );
  197. bool SsrPPressOn (
  198. IN SsrActionVerb lActionVerb,
  199. IN LONG lActionType,
  200. IN HRESULT hr
  201. );
  202. const BSTR
  203. SsrPGetDirectory (
  204. IN SsrActionVerb lActionVerb,
  205. IN BOOL bScriptFile
  206. );
  207. HRESULT
  208. SsrPDoDCOMSettings (
  209. bool bReg
  210. );