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.

548 lines
15 KiB

  1. /****************************************************************************
  2. Copyright information : Copyright (c) 1998-1999 Microsoft Corporation
  3. File Name : CommandSwitches.h
  4. Project Name : WMI Command Line
  5. Author Name : Ch.Sriramachandramurthy
  6. Date of Creation (dd/mm/yy) : 27th-September-2000
  7. Version Number : 1.0
  8. Brief Description : This file consist of class declaration of
  9. class CommandSwitches
  10. Revision History :
  11. Last Modified By : Ch. Sriramachandramurthy
  12. Last Modified Date : 20th-March-2001
  13. ****************************************************************************/
  14. // CommandSwitches.h : header file
  15. //
  16. /*-------------------------------------------------------------------
  17. Class Name : CCommandSwitches
  18. Class Type : Concrete
  19. Brief Description : This class encapsulates the functionality needed
  20. for accessing and storing the command switches
  21. information, which will be used by Parsing,
  22. Execution and Format Engines depending upon the
  23. applicability.
  24. Super Classes : None
  25. Sub Classes : None
  26. Classes Used : None
  27. Interfaces Used : None
  28. --------------------------------------------------------------------*/
  29. #pragma once
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CCommandSwitches
  32. class CCommandSwitches
  33. {
  34. public:
  35. // Construction
  36. CCommandSwitches();
  37. // Destruction
  38. ~CCommandSwitches();
  39. // Restrict Assignment
  40. CCommandSwitches& operator=(CCommandSwitches& rCmdSwitches);
  41. // Attributes
  42. private:
  43. //command string
  44. _TCHAR *m_pszCommandInput;
  45. //alias name
  46. _TCHAR *m_pszAliasName;
  47. //alias description
  48. _TCHAR *m_pszAliasDesc;
  49. //class path
  50. _TCHAR *m_pszClassPath;
  51. //path expression
  52. _TCHAR *m_pszPathExpr;
  53. //where expression
  54. _TCHAR *m_pszWhereExpr;
  55. //verb name - standard|userdefined verb
  56. _TCHAR *m_pszVerb;
  57. //method name
  58. _TCHAR *m_pszMethodName;
  59. //XSLT details vector.
  60. XSLTDETVECTOR m_xdvXSLTDetVec;
  61. //alias target class
  62. _TCHAR *m_pszAliasTarget;
  63. //XML stream
  64. BSTR m_bstrXML;
  65. //session success - flag.
  66. BOOL m_bSuccess;
  67. //HRESULT
  68. HRESULT m_hResult;
  69. //friendly names|trasnlate tables - map
  70. BSTRMAP m_bmAlsFrnNmsDesOrTrnsTblEntrs;
  71. //property(s) details - map
  72. PROPDETMAP m_pdmPropDet;
  73. //method(s) details - map
  74. METHDETMAP m_mdmMethDet;
  75. //input property(s) - vector
  76. CHARVECTOR m_cvProperties;
  77. //PWhere param(s) - vector
  78. CHARVECTOR m_cvPWhereParams;
  79. //Translate table entry(s) - vector
  80. CHARVECTOR m_cvTrnsTablesList;
  81. //input method param(s) - map
  82. BSTRMAP m_bmParameters;
  83. //verb interactive mode
  84. WMICLIINT m_nInteractiveMode;
  85. ///EVERY interval value
  86. ULONG m_ulInterval;
  87. ///tablename - TRANSLATE:<tablename>
  88. _TCHAR *m_pszTransTableName;
  89. //listformat - LISTFORMAT type
  90. _TCHAR *m_pszListFormat;
  91. // Errata code
  92. UINT m_uErrataCode;
  93. // Message code
  94. UINT m_uInformationCode;
  95. // Credentials flag
  96. BOOL m_bCredFlag;
  97. // parameterized string with '#' as place holder(s) for input value(s)
  98. _TCHAR *m_pszPWhereExpr;
  99. // COM error object
  100. _com_error *m_pComError;
  101. // IWbemClassObject, to store output parameters of method execution.
  102. IWbemClassObject *m_pIMethOutParam;
  103. // alias connection information
  104. // alias user name
  105. _TCHAR *m_pszUser;
  106. // alias user password
  107. _TCHAR *m_pszPassword;
  108. // alias node
  109. _TCHAR *m_pszNode;
  110. // alias locale
  111. _TCHAR *m_pszLocale;
  112. // alias namespace
  113. _TCHAR *m_pszNamespace;
  114. // alias authority type.
  115. _TCHAR *m_pszAuthority;
  116. // Type of the verb ( CLASSMETHOD/STDVERB/CMDLINE ).
  117. VERBTYPE m_vtVerbType;
  118. // Verb derivation string
  119. _TCHAR *m_pszVerbDerivation;
  120. // flag to check that WHERE is specified explicitly
  121. BOOL m_bExplicitWhereExpr;
  122. ALSFMTDETMAP m_afdAlsFmtDet;
  123. BOOL m_bTranslateFirst;
  124. // /RESULTCLASS switch value of ASSOC verb
  125. _TCHAR *m_pszResultClassName;
  126. // /RESULTROLE switch value of ASSOC verb
  127. _TCHAR *m_pszResultRoleName;
  128. // /ASSOCCLASS switch value of ASSOC verb
  129. _TCHAR *m_pszAssocClassName;
  130. // count for /REPEAT:N
  131. ULONG m_ulRepeatCount;
  132. // Flag for availibility of methods.
  133. BOOL m_bMethAvail;
  134. // Flag for availibility of writable properties.
  135. BOOL m_bWritePropsAvail;
  136. // Flag for availibility list formats.
  137. BOOL m_bLISTFrmsAvail;
  138. //input property(s) - vector
  139. CHARVECTOR m_cvInteractiveProperties;
  140. // Flag to specify Named Parameter List.
  141. BOOL m_bNamedParamList;
  142. // Flag to check if every switch is specified.
  143. BOOL m_bEverySwitch ;
  144. // Flag to check if output switch is specified.
  145. BOOL m_bOutputSwitch ;
  146. //the query formed of the given command .
  147. BSTR m_bstrFormedQuery;
  148. BOOL m_bSysProp;
  149. // Operations
  150. public:
  151. //Assigns the parameter passed to m_pszCommandInput
  152. BOOL SetCommandInput(const _TCHAR* pszCommandInput);
  153. //Assigns the parameter passed to m_pszAliasName that represents
  154. //Alias object.
  155. BOOL SetAliasName(const _TCHAR* pszAliasName);
  156. // Sets the alias description
  157. BOOL SetAliasDesc(const _TCHAR* pszAliasDesc);
  158. // Sets the alias credentials information
  159. BOOL SetAliasUser(const _TCHAR* pszUserName);
  160. BOOL SetAliasNode(const _TCHAR* pszNode);
  161. BOOL SetAliasPassword(const _TCHAR* pszPassword);
  162. BOOL SetAliasLocale(const _TCHAR* pszLocale);
  163. BOOL SetAliasNamespace(const _TCHAR* pszNamespace);
  164. BOOL SetAliasAuthorityPrinciple(const _TCHAR* pszAuthority);
  165. //Assigns the parameter passed to m_pszClassPath.
  166. BOOL SetClassPath(const _TCHAR* pszClassPath);
  167. //Assigns the parameter passed to m_pszPathExpr.
  168. BOOL SetPathExpression(const _TCHAR* pszPathExpr);
  169. //Assigns the parameter passed to m_pszWhereExpr
  170. BOOL SetWhereExpression(const _TCHAR* pszWhereExpr);
  171. //Assigns the parameter passed to m_pszMathodName.
  172. BOOL SetMethodName(const _TCHAR* pszMethodName);
  173. //Adds to vector held by m_xdvXSLDetVec.
  174. void AddToXSLTDetailsVector(XSLTDET xdXSLTDet);
  175. //Assigns the parameter passed to m_pszVerbName.
  176. BOOL SetVerbName(const _TCHAR* pszVerbName);
  177. //Assigns the parameter passed to m_pszSesionFilePath
  178. BOOL SetSessionFilePath(const _TCHAR* pszSessionFilePath);
  179. //Assigns the parameter passed to m_bstrXML, is used to store XML file
  180. //Name that contains result set.
  181. BOOL SetXMLResultSet(const BSTR bstrXMLResultSet);
  182. //Assigns the parameter passed to m_pszAliasTarget, is used in Parsing
  183. //Engine to avail the alias object informations.
  184. BOOL SetAliasTarget(const _TCHAR* pszAliasTarget);
  185. //Adds string that passed through parameter to m_bmParameters, which is
  186. //a data member of type BSTRMAP
  187. BOOL AddToPropertyList(_TCHAR* const pszProperty);
  188. BOOL AddToTrnsTablesList(_TCHAR* const pszTableName);
  189. //Adds bstrKey and bstrValue passed as parameters to m_bmParameters,which
  190. //is type of BSTRMAP data structure
  191. BOOL AddToParameterMap(_bstr_t bstrKey, _bstr_t bstrValue);
  192. //Adds bstrKey and bstrValue passed as parameters to m_bmParameters,which
  193. //is type of ALSFMTDETMAP data structure
  194. BOOL AddToAliasFormatDetMap(_bstr_t bstrKey, BSTRVECTOR bvProps);
  195. //Adds bstrKey and bstrValue passed as parameters to
  196. //m_bmAlsFrnNmsDesOrTrnsTblEntrs,
  197. //which is type of BSTRMAP
  198. BOOL AddToAlsFrnNmsOrTrnsTblMap(_bstr_t bstrKey, _bstr_t bstrValue);
  199. //Adds bstrKey and mdMethDet passed as parameters to m_mdmMethDet,
  200. //which is type of METHDETMAP.
  201. BOOL AddToMethDetMap(_bstr_t bstrKey, METHODDETAILS mdMethDet);
  202. //Adds bstrKey and pdPropDet passed as parameters to m_pdmPropDet,
  203. //which is type of PROPERTYDETALS
  204. BOOL AddToPropDetMap(_bstr_t bstrKey, PROPERTYDETAILS pdPropDet);
  205. //Assigns the Boolean variable to m_bSuccess
  206. void SetSuccessFlag(BOOL bSuccess);
  207. //Assigns the string variable to m_pszTransTableName.
  208. BOOL SetTranslateTableName(const _TCHAR* pszTransTableName);
  209. //Assigns the integer value to m_nInterval
  210. BOOL SetRetrievalInterval(const ULONG lInterval);
  211. //Assigns the parameter value to m_ListFormat
  212. BOOL SetListFormat(const _TCHAR *pszListFormat);
  213. //Set|Reset the verb interactive mode
  214. void SetInteractiveMode(WMICLIINT nInteractiveMode);
  215. //Stores the parameter in map array
  216. BOOL AddToPWhereParamsList(_TCHAR* const pszParameter);
  217. //Assigns the value to m_uErrataCode
  218. void SetErrataCode(const UINT uErrataCode);
  219. //Assigns the value to m_uInformationCode
  220. void SetInformationCode(const UINT uInformationCode);
  221. // Assigns the string to m_pszPWhereExpr
  222. BOOL SetPWhereExpr(const _TCHAR* pszPWhereExpr);
  223. // Assigns the parameter passed to m_pComError that consist of
  224. // error info
  225. void SetCOMError(_com_error& rComError);
  226. // Set m_pIMethExecOutParam.
  227. BOOL SetMethExecOutParam(IWbemClassObject* pIMethOutParam);
  228. // Set m_vtVerbType to passed flag.
  229. void SetVerbType( VERBTYPE vtVerbType);
  230. // Set m_pszVerbDerivation.
  231. BOOL SetVerbDerivation( const _TCHAR* pszVerbDerivation );
  232. //Set the credential flag status
  233. void SetCredentialsFlag(BOOL bCredFlag);
  234. // Set the explicit where flag
  235. void SetExplicitWhereExprFlag(BOOL bWhere);
  236. //Assigns the string variable to m_pszResultClassName.
  237. BOOL SetResultClassName(const _TCHAR* pszResultClassName);
  238. //Assigns the string variable to m_pszResultRoleName.
  239. BOOL SetResultRoleName(const _TCHAR* pszResultRoleName);
  240. //Assigns the string variable to m_pszAssocClassName.
  241. BOOL SetAssocClassName(const _TCHAR* pszAssocClassName);
  242. // Set repeat count.
  243. BOOL SetRepeatCount(const ULONG lRepCount);
  244. // Set methods available.
  245. void SetMethodsAvailable(BOOL bFlag);
  246. // Retruns the alias description
  247. _TCHAR* GetAliasDesc();
  248. //Returns the alias name held by the object
  249. _TCHAR* GetAliasName();
  250. //Returns the class path held by the object
  251. _TCHAR* GetClassPath();
  252. // Return the alias credentials information.
  253. _TCHAR* GetAliasUser();
  254. _TCHAR* GetAliasNode();
  255. _TCHAR* GetAliasPassword();
  256. _TCHAR* GetAliasLocale();
  257. _TCHAR* GetAliasNamespace();
  258. _TCHAR* GetAliasAuthorityPrinciple();
  259. //Returns the path expression held by the object
  260. _TCHAR* GetPathExpression();
  261. //Returns the where expression held by the object
  262. _TCHAR* GetWhereExpression();
  263. //Returns the method name held by the object
  264. _TCHAR* GetMethodName();
  265. //Returns the XSLTDetVec held by the object.
  266. XSLTDETVECTOR& GetXSLTDetailsVector();
  267. //Returns the verb name held by the object
  268. _TCHAR* GetVerbName();
  269. //Returns the session file path held by the object
  270. _TCHAR* GetSessionFilePath();
  271. //Returns the alias target held by the object
  272. _TCHAR* GetAliasTarget();
  273. //Returns the command input held by the object
  274. _TCHAR* GetCommandInput();
  275. //Returns the XML result set held by the object.
  276. BSTR GetXMLResultSet();
  277. //Returns the property held by the object.
  278. CHARVECTOR& GetPropertyList();
  279. //Returns the tables held by the object.
  280. CHARVECTOR& GetTrnsTablesList();
  281. //Returns the parameter map containing both key and value
  282. BSTRMAP& GetParameterMap();
  283. //Returns the alias formats map
  284. ALSFMTDETMAP& GetAliasFormatDetMap();
  285. //Returns the alias friendly names map held by the object
  286. BSTRMAP& GetAlsFrnNmsOrTrnsTblMap();
  287. //Returns the method details map held by the object
  288. METHDETMAP& GetMethDetMap();
  289. //Returns the alias property details map held by the object
  290. PROPDETMAP& GetPropDetMap();
  291. //Returns the success flag held by the object
  292. BOOL GetSuccessFlag();
  293. //Returns the value of m_ulInterval.
  294. ULONG GetRetrievalInterval();
  295. //Returns the value of m_pszTransTableName.
  296. _TCHAR* GetTranslateTableName();
  297. //Returns the list format type m_ListFormat
  298. _TCHAR* GetListFormat();
  299. //Returns the name of XSL file used for specifying format for dumping.
  300. _TCHAR* GetDumpXSLFormat();
  301. //returns the verb interactive mode
  302. WMICLIINT GetInteractiveMode();
  303. //Returns the PWhereParameters list
  304. CHARVECTOR& GetPWhereParamsList();
  305. //This function gets the class of Alias
  306. void GetClassOfAliasTarget(_bstr_t& bstrClassName);
  307. //returns the error code
  308. UINT GetErrataCode();
  309. //returns the information code
  310. UINT GetInformationCode();
  311. // returns the PWhere expression - m_pszPWhereExpr
  312. _TCHAR* GetPWhereExpr();
  313. // Get m_pIMethExecOutParam.
  314. IWbemClassObject* GetMethExecOutParam();
  315. // Get m_vtVerbType.
  316. VERBTYPE GetVerbType();
  317. // Get m_pszVerbDerivation.
  318. _TCHAR* GetVerbDerivation();
  319. // Returns the credential flag status
  320. BOOL GetCredentialsFlagStatus();
  321. // Returns the explicit where flag status
  322. BOOL GetExplicitWhereExprFlag();
  323. // Get m_uRepeatCount count.
  324. ULONG GetRepeatCount();
  325. // This function returns the COMError object
  326. _com_error* CCommandSwitches::GetCOMError();
  327. // Update the parameter value
  328. BOOL UpdateParameterValue(_bstr_t bstrKey, _bstr_t bstrValue);
  329. // Free the COM error
  330. void FreeCOMError();
  331. // Clear cvPropertyList.
  332. void ClearPropertyList();
  333. // Initiliaze the necessary member variables
  334. void Initialize();
  335. // Free the member variables
  336. void Uninitialize();
  337. // This function sets the the order of the format and
  338. // translate switch flag
  339. void SetTranslateFirstFlag(BOOL bTranslateFirst);
  340. // This function returns the order of the format and
  341. // translate switch flag
  342. BOOL GetTranslateFirstFlag();
  343. //Returns the value of m_pszResultClassName.
  344. _TCHAR* GetResultClassName();
  345. //Returns the value of m_pszResultRoleName.
  346. _TCHAR* GetResultRoleName();
  347. //Returns the value of m_pszAssocClassName.
  348. _TCHAR* GetAssocClassName();
  349. // Get methods available.
  350. BOOL GetMethodsAvailable();
  351. // Set writable properties available flag.
  352. void SetWriteablePropsAvailable(BOOL bFlag);
  353. // Get writable properties available flag.
  354. BOOL GetWriteablePropsAvailable();
  355. // Set LIST Formats available flag.
  356. void SetLISTFormatsAvailable(BOOL bFlag);
  357. // Get LIST Formats Available flag.
  358. BOOL GetLISTFormatsAvailable();
  359. BOOL AddToInteractivePropertyList(_TCHAR* const pszProperty);
  360. CHARVECTOR& GetInteractivePropertyList();
  361. // Set m_bNamedParamList flag.
  362. void SetNamedParamListFlag(BOOL bFlag);
  363. // Get m_bNamedParamList flag.
  364. BOOL GetNamedParamListFlag();
  365. // Clear or nullify XSL Details vector.
  366. void ClearXSLTDetailsVector();
  367. //every
  368. // Set m_bEverySwitch flag.
  369. void SetEverySwitchFlag(BOOL bFlag);
  370. // Get m_bEverySwitch flag.
  371. BOOL GetEverySwitchFlag();
  372. // Set m_bOutputSwitch flag.
  373. void SetOutputSwitchFlag(BOOL bFlag);
  374. // Get m_bOutputSwitch flag.
  375. BOOL GetOutputSwitchFlag();
  376. //Sets the m_bstrFormedQuery
  377. BOOL SetFormedQuery(const BSTR bstrFormedQuery);
  378. //Returns the query formed for the given command.
  379. BSTR GetFormedQuery();
  380. // Get the status of sytem properties flag
  381. BOOL GetSysPropFlag();
  382. // Sets the status of system properties flag
  383. void SetSysPropFlag(BOOL bSysProp);
  384. };