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.

1995 lines
60 KiB

  1. /****************************************************************************
  2. Copyright information : Copyright (c) 1998-1999 Microsoft Corporation
  3. File Name : GlobalSwitches.cpp
  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 class encapsulates the functionality needed
  9. for accessing and storing the global switches
  10. information, which will be used by Parsing,
  11. Execution and Format Engines depending upon the
  12. applicablity.
  13. Revision History :
  14. Last Modified by : Ch. Sriramachandramurthy
  15. Last Modified on : 11th-April-2001
  16. ****************************************************************************/
  17. // GlobalSwitches.cpp : implementation file
  18. //
  19. #include "precomp.h"
  20. #include "GlobalSwitches.h"
  21. /*------------------------------------------------------------------------
  22. Name :CGlobalSwitches
  23. Synopsis :This function initializes the member variables when
  24. an object of the class type is instantiated
  25. Type :Constructor
  26. Input parameters :None
  27. Output parameters :None
  28. Return Type :None
  29. Global Variables :None
  30. Calling Syntax :None
  31. Notes :None
  32. ------------------------------------------------------------------------*/
  33. CGlobalSwitches::CGlobalSwitches()
  34. {
  35. m_pszNameSpace = NULL;
  36. m_pszRole = NULL;
  37. m_pszNode = NULL;
  38. m_pszLocale = NULL;
  39. m_pszAuthority = NULL;
  40. m_pszUser = NULL;
  41. m_pszPassword = NULL;
  42. m_pszRecordPath = NULL;
  43. m_bPrivileges = TRUE;
  44. m_uConnInfoFlag = 0;
  45. m_bRoleFlag = TRUE;
  46. m_bNSFlag = TRUE;
  47. m_bLocaleFlag = TRUE;
  48. m_bRPChange = FALSE;
  49. m_bAggregateFlag = TRUE;
  50. // default impersonation level is IMPERSONATE
  51. m_ImpLevel = IMPERSONATE;
  52. // default authentication level is DEFAULT
  53. m_AuthLevel = AUTHDEFAULT;
  54. // Trace mode if OFF by default
  55. m_bTrace = FALSE;
  56. // Interactive mode is OFF by default
  57. m_bInteractive = FALSE;
  58. // Help flag is OFF by default
  59. m_bHelp = FALSE;
  60. // Default help option is BRIEF
  61. m_HelpOption = HELPBRIEF;
  62. m_bAskForPassFlag = FALSE;
  63. m_bFailFast = FALSE;
  64. m_opsOutputOpt = STDOUT;
  65. m_opsAppendOpt = STDOUT;
  66. m_pszOutputFileName = NULL;
  67. m_fpOutFile = NULL;
  68. m_pszAppendFileName = NULL;
  69. m_fpAppendFile = NULL;
  70. m_nSeqNum = 0;
  71. m_pszLoggedOnUser = NULL;
  72. m_pszNodeName = NULL;
  73. m_pszStartTime = NULL;
  74. }
  75. /*------------------------------------------------------------------------
  76. Name :~CGlobalSwitches
  77. Synopsis :This function Uninitializes the member variables when
  78. an object of the class type is instantiated
  79. Type :Destructor
  80. Input parameters :None
  81. Output parameters :None
  82. Return Type :None
  83. Global Variables :None
  84. Calling Syntax :None
  85. Notes :None
  86. ------------------------------------------------------------------------*/
  87. CGlobalSwitches::~CGlobalSwitches()
  88. {
  89. Uninitialize();
  90. }
  91. /*------------------------------------------------------------------------
  92. Name :Initialize
  93. Synopsis :This function initializes the necessary member
  94. variables.
  95. Type :Member Function
  96. Input parameters :None
  97. Output parameters :None
  98. Return Type :None
  99. Global Variables :None
  100. Calling Syntax :Initialize()
  101. Notes :None
  102. ------------------------------------------------------------------------*/
  103. void CGlobalSwitches::Initialize() throw(WMICLIINT)
  104. {
  105. static BOOL bFirst = TRUE;
  106. try
  107. {
  108. if (bFirst)
  109. {
  110. // NAMESPACE
  111. // Set the default namespace to 'root\cimv2'
  112. m_pszNameSpace = new _TCHAR [BUFFER32];
  113. // Check for memory allocation failure.
  114. if (m_pszNameSpace == NULL)
  115. throw OUT_OF_MEMORY;
  116. lstrcpy(m_pszNameSpace, CLI_NAMESPACE_DEFAULT);
  117. // Set the default role as 'root\cli'
  118. m_pszRole = new _TCHAR [BUFFER32];
  119. // Check for memory allocation failure
  120. if (m_pszRole == NULL)
  121. throw OUT_OF_MEMORY;
  122. lstrcpy(m_pszRole, CLI_ROLE_DEFAULT);
  123. // Set the system default locale in the format ms_xxx
  124. m_pszLocale = new _TCHAR [BUFFER32];
  125. // Check for memory allocation failure
  126. if (m_pszLocale == NULL)
  127. throw OUT_OF_MEMORY;
  128. _stprintf(m_pszLocale, _T("ms_%x"), GetSystemDefaultLangID());
  129. m_pszNodeName = new _TCHAR [MAX_COMPUTERNAME_LENGTH + 1];
  130. if (m_pszNodeName == NULL)
  131. throw OUT_OF_MEMORY;
  132. DWORD dwCompNameBufferSize = MAX_COMPUTERNAME_LENGTH + 1;
  133. if (GetComputerName(m_pszNodeName, &dwCompNameBufferSize))
  134. {
  135. m_pszNodeName[MAX_COMPUTERNAME_LENGTH] = _T('\0');
  136. }
  137. else
  138. lstrcpy(m_pszNodeName, L"N/A");
  139. // current node is the default.
  140. m_pszNode = new _TCHAR [lstrlen(m_pszNodeName)+1];
  141. // Check for memory allocation failure
  142. if (m_pszNode == NULL)
  143. throw OUT_OF_MEMORY;
  144. lstrcpy(m_pszNode, m_pszNodeName);
  145. ULONG nSize = 0;
  146. if(!GetUserNameEx(NameSamCompatible, NULL, &nSize))
  147. {
  148. m_pszLoggedOnUser = new _TCHAR [nSize + 1];
  149. if (m_pszLoggedOnUser == NULL)
  150. throw OUT_OF_MEMORY;
  151. if (!GetUserNameEx(NameSamCompatible, m_pszLoggedOnUser, &nSize))
  152. lstrcpy(m_pszLoggedOnUser, L"N/A");
  153. }
  154. if (!AddToNodesList(m_pszNode))
  155. throw OUT_OF_MEMORY;
  156. // Populate the IMPLEVEL mappings
  157. m_cimImpLevel.insert(CHARINTMAP::value_type(_bstr_t(L"ANONYMOUS"), 1));
  158. m_cimImpLevel.insert(CHARINTMAP::value_type(_bstr_t(L"IDENTIFY"), 2));
  159. m_cimImpLevel.insert(CHARINTMAP::value_type(_bstr_t(L"IMPERSONATE"),3));
  160. m_cimImpLevel.insert(CHARINTMAP::value_type(_bstr_t(L"DELEGATE"), 4));
  161. // Populate the AUTHLEVEL mappings
  162. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"DEFAULT"), 0));
  163. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"NONE"), 1));
  164. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"CONNECT"), 2));
  165. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"CALL"), 3));
  166. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"PKT"), 4));
  167. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"PKTINTEGRITY"),5));
  168. m_cimAuthLevel.insert(CHARINTMAP::value_type(_bstr_t(L"PKTPRIVACY"), 6));
  169. bFirst = FALSE;
  170. }
  171. }
  172. catch(_com_error& e)
  173. {
  174. _com_issue_error(e.Error());
  175. }
  176. m_HelpOption = HELPBRIEF;
  177. }
  178. /*------------------------------------------------------------------------
  179. Name :Uninitialize
  180. Synopsis :This function uninitializes the member variables
  181. when the execution of a command string issued on the
  182. command line is completed.
  183. Type :Member Function
  184. Input parameters :None
  185. Output parameters :None
  186. Return Type :None
  187. Global Variables :None
  188. Calling Syntax :Uninitialize()
  189. Notes :None
  190. ------------------------------------------------------------------------*/
  191. void CGlobalSwitches::Uninitialize()
  192. {
  193. SAFEDELETE(m_pszAuthority);
  194. SAFEDELETE(m_pszNameSpace);
  195. SAFEDELETE(m_pszRole);
  196. SAFEDELETE(m_pszLocale);
  197. SAFEDELETE(m_pszNode);
  198. CleanUpCharVector(m_cvNodesList);
  199. SAFEDELETE(m_pszUser);
  200. SAFEDELETE(m_pszPassword);
  201. SAFEDELETE(m_pszRecordPath);
  202. SAFEDELETE(m_pszOutputFileName);
  203. SAFEDELETE(m_pszAppendFileName);
  204. if ( m_fpOutFile != NULL )
  205. {
  206. fclose(m_fpOutFile);
  207. m_fpOutFile = NULL;
  208. }
  209. if ( m_fpAppendFile != NULL )
  210. {
  211. fclose(m_fpAppendFile);
  212. m_fpAppendFile = NULL;
  213. }
  214. m_bHelp = FALSE;
  215. m_bTrace = FALSE;
  216. m_bInteractive = FALSE;
  217. m_HelpOption = HELPBRIEF;
  218. m_AuthLevel = AUTHPKT;
  219. m_ImpLevel = IMPERSONATE;
  220. m_uConnInfoFlag = 0;
  221. m_cimAuthLevel.clear();
  222. m_cimImpLevel.clear();
  223. m_nSeqNum = 0;
  224. SAFEDELETE(m_pszLoggedOnUser);
  225. SAFEDELETE(m_pszNodeName);
  226. SAFEDELETE(m_pszStartTime);
  227. }
  228. /*------------------------------------------------------------------------
  229. Name :SetAuthority
  230. Synopsis :This function sets the authority value defined with
  231. alias to m_pszAuthority.
  232. Type :Member Function
  233. Input parameters :
  234. pszAuthority - string type, contains the authority value
  235. Output parameters :None
  236. Return Type :BOOL
  237. Global Variables :None
  238. Calling Syntax :SetAuthority(pszAuthority)
  239. Notes :None
  240. ------------------------------------------------------------------------*/
  241. BOOL CGlobalSwitches::SetAuthority(_TCHAR* pszAuthority)
  242. {
  243. BOOL bResult = TRUE;
  244. SAFEDELETE(m_pszAuthority);
  245. if(pszAuthority)
  246. {
  247. m_pszAuthority = new _TCHAR [lstrlen(pszAuthority)+1];
  248. if (m_pszAuthority)
  249. lstrcpy(m_pszAuthority, pszAuthority);
  250. else
  251. bResult = FALSE;
  252. }
  253. return bResult;
  254. }
  255. /*------------------------------------------------------------------------
  256. Name :SetNameSpace
  257. Synopsis :This function Sets the namespace passed in parameter
  258. to m_pszNameSpace.
  259. Type :Member Function
  260. Input parameters :
  261. pszNameSpace -String type,contains Namespace specified in the command
  262. AliasFlag -Boolean type,specifies whether alias flag is set or not
  263. Output parameters :None
  264. Return Type :BOOL
  265. Global Variables :None
  266. Calling Syntax :SetNameSpace(pszNameSpace)
  267. Notes :None
  268. ------------------------------------------------------------------------*/
  269. BOOL CGlobalSwitches::SetNameSpace(_TCHAR* pszNamespace)
  270. {
  271. BOOL bResult = TRUE;
  272. if(pszNamespace)
  273. {
  274. // If the value specified is not _T("")
  275. if( !CompareTokens(pszNamespace, CLI_TOKEN_NULL) )
  276. {
  277. // Check if the same value is specified for the /NAMESPACE.
  278. if (!CompareTokens(pszNamespace, m_pszNameSpace))
  279. {
  280. SAFEDELETE(m_pszNameSpace);
  281. m_pszNameSpace = new _TCHAR [lstrlen(pszNamespace)+1];
  282. if (m_pszNameSpace)
  283. {
  284. lstrcpy(m_pszNameSpace, pszNamespace);
  285. m_bNSFlag = TRUE;
  286. }
  287. else
  288. bResult = FALSE;
  289. }
  290. }
  291. // set back to default
  292. else
  293. {
  294. // If the current namespace is not the default namespace
  295. if (!CompareTokens(m_pszRole, CLI_NAMESPACE_DEFAULT))
  296. {
  297. SAFEDELETE(m_pszNameSpace)
  298. m_pszNameSpace = new _TCHAR [BUFFER255];
  299. if (m_pszNameSpace)
  300. {
  301. lstrcpy(m_pszNameSpace, CLI_NAMESPACE_DEFAULT);
  302. m_bNSFlag = TRUE;
  303. }
  304. else
  305. bResult = FALSE;
  306. }
  307. }
  308. }
  309. return bResult;
  310. }
  311. /*------------------------------------------------------------------------
  312. Name :SetRole
  313. Synopsis :This function Sets the role passed in parameter
  314. to m_pszRole.
  315. Type :Member Function
  316. Input parameters :
  317. pszRole -String type,contains Role specified in the command
  318. Output parameters :None
  319. Return Type :BOOL
  320. Global Variables :None
  321. Calling Syntax :SetRole(pszRole)
  322. Notes :None
  323. ------------------------------------------------------------------------*/
  324. BOOL CGlobalSwitches::SetRole(_TCHAR* pszRole)
  325. {
  326. BOOL bResult = TRUE;
  327. if(pszRole)
  328. {
  329. // If the value specified is not _T("")
  330. if( !CompareTokens(pszRole, CLI_TOKEN_NULL) )
  331. {
  332. // Check if the same value is specified for the /ROLE.
  333. if (!CompareTokens(pszRole, m_pszRole))
  334. {
  335. SAFEDELETE(m_pszRole);
  336. m_pszRole = new _TCHAR [lstrlen(pszRole)+1];
  337. if (m_pszRole)
  338. {
  339. lstrcpy(m_pszRole, pszRole);
  340. m_bRoleFlag = TRUE;
  341. m_bLocaleFlag = TRUE;
  342. }
  343. else
  344. bResult = FALSE;
  345. }
  346. }
  347. // set back to default
  348. else
  349. {
  350. // If the current role is not the default role
  351. if (!CompareTokens(m_pszRole, CLI_ROLE_DEFAULT))
  352. {
  353. SAFEDELETE(m_pszRole)
  354. m_pszRole = new _TCHAR [BUFFER255];
  355. if (m_pszRole)
  356. {
  357. lstrcpy(m_pszRole, CLI_ROLE_DEFAULT);
  358. m_bRoleFlag = TRUE;
  359. m_bLocaleFlag = TRUE;
  360. }
  361. else
  362. bResult = FALSE;
  363. }
  364. }
  365. }
  366. return bResult;
  367. }
  368. /*------------------------------------------------------------------------
  369. Name :SetLocale
  370. Synopsis :This function Assigns the locale passed in parameter
  371. to m_pszLocale.
  372. Type :Member Function
  373. Input parameters :
  374. pszLocale -String type,It contains Locale option specified in the
  375. command
  376. Output parameters :None
  377. Return Type :BOOL
  378. Global Variables :None
  379. Calling Syntax :SetLocale(pszLocale)
  380. Notes :None
  381. ------------------------------------------------------------------------*/
  382. BOOL CGlobalSwitches::SetLocale(_TCHAR* pszLocale)
  383. {
  384. BOOL bResult = TRUE;
  385. if(pszLocale)
  386. {
  387. // If the value specified is not _T("")
  388. if (!CompareTokens(pszLocale, CLI_TOKEN_NULL))
  389. {
  390. // Check if the same value is specified for the /LOCALE.
  391. if (!CompareTokens(m_pszLocale, pszLocale))
  392. {
  393. SAFEDELETE(m_pszLocale);
  394. m_pszLocale = new _TCHAR [lstrlen(pszLocale)+1];
  395. if (m_pszLocale)
  396. {
  397. lstrcpy(m_pszLocale, pszLocale);
  398. m_uConnInfoFlag |= LOCALE;
  399. m_bLocaleFlag = TRUE;
  400. m_bRoleFlag = TRUE;
  401. m_bNSFlag = TRUE;
  402. }
  403. else
  404. bResult = FALSE;
  405. }
  406. }
  407. // If the value specified is _T("") - set to default system locale.
  408. else
  409. {
  410. _TCHAR szLocale[BUFFER32] = NULL_STRING;
  411. _stprintf(szLocale, _T("ms_%x"), GetSystemDefaultLangID());
  412. // If the current role is not the default role
  413. if (!CompareTokens(m_pszLocale, szLocale))
  414. {
  415. SAFEDELETE(m_pszLocale);
  416. m_pszLocale = new _TCHAR [BUFFER32];
  417. if (m_pszLocale)
  418. {
  419. m_uConnInfoFlag &= ~LOCALE;
  420. lstrcpy(m_pszLocale, szLocale);
  421. m_bLocaleFlag = TRUE;
  422. m_bRoleFlag = TRUE;
  423. m_bNSFlag = TRUE;
  424. }
  425. else
  426. bResult = FALSE;
  427. }
  428. }
  429. }
  430. return bResult;
  431. }
  432. /*------------------------------------------------------------------------
  433. Name :AddToNodesList
  434. Synopsis :This function adds the node passed in parameter
  435. to m_cvNodesList
  436. Type :Member Function
  437. Input parameters :
  438. pszNode - String type,contains Node option specified in the
  439. command
  440. Output parameters :None
  441. Return Type :void
  442. Global Variables :BOOL
  443. Calling Syntax :AddToNodesList(pszNode)
  444. Notes :None
  445. ------------------------------------------------------------------------*/
  446. BOOL CGlobalSwitches::AddToNodesList(_TCHAR* pszNode)
  447. {
  448. _TCHAR* pszTempNode = NULL;
  449. BOOL bRet = TRUE;
  450. if (!CompareTokens(pszNode, CLI_TOKEN_NULL) &&
  451. !CompareTokens(pszNode, CLI_TOKEN_DOT) &&
  452. !CompareTokens(pszNode, CLI_TOKEN_LOCALHOST) &&
  453. !CompareTokens(pszNode, m_pszNodeName))
  454. {
  455. pszTempNode = new _TCHAR [ lstrlen ( pszNode ) + 1 ];
  456. if (pszTempNode)
  457. lstrcpy(pszTempNode, pszNode);
  458. else
  459. bRet = FALSE;
  460. }
  461. else
  462. {
  463. // "." specifies current node
  464. SAFEDELETE(m_pszNode);
  465. m_pszNode = new _TCHAR [ lstrlen (m_pszNodeName) + 1 ];
  466. if (m_pszNodeName)
  467. {
  468. lstrcpy(m_pszNode, m_pszNodeName);
  469. pszTempNode = new _TCHAR [ lstrlen (m_pszNodeName) + 1 ];
  470. if (pszTempNode)
  471. lstrcpy(pszTempNode, m_pszNodeName);
  472. else
  473. bRet = FALSE;
  474. }
  475. else
  476. bRet = FALSE;
  477. }
  478. if (bRet)
  479. {
  480. CHARVECTOR::iterator tempIterator;
  481. if ( !Find(m_cvNodesList, pszTempNode, tempIterator) )
  482. m_cvNodesList.push_back(pszTempNode);
  483. else if ( CompareTokens(pszTempNode, m_pszNodeName) == TRUE )
  484. {
  485. BOOL bFound = FALSE;
  486. tempIterator = m_cvNodesList.begin();
  487. while ( tempIterator != m_cvNodesList.end() )
  488. {
  489. if ( tempIterator != m_cvNodesList.begin() )
  490. {
  491. if(CompareTokens(*tempIterator, m_pszNodeName) == TRUE)
  492. {
  493. bFound = TRUE;
  494. break;
  495. }
  496. }
  497. tempIterator++;
  498. }
  499. if(bFound == FALSE)
  500. m_cvNodesList.push_back(pszTempNode);
  501. else
  502. SAFEDELETE(pszTempNode);
  503. }
  504. else
  505. SAFEDELETE(pszTempNode);
  506. }
  507. return bRet;
  508. }
  509. /*------------------------------------------------------------------------
  510. Name :SetUser
  511. Synopsis :This function Assigns the user passed in parameter
  512. to m_pszUser
  513. Type :Member Function
  514. Input parameters :
  515. pszUser -String type,contains User option specified in the
  516. command.
  517. Output parameters :None
  518. Return Type :BOOL
  519. Global Variables :None
  520. Calling Syntax :SetUser(pszUser)
  521. Notes :None
  522. ------------------------------------------------------------------------*/
  523. BOOL CGlobalSwitches::SetUser(_TCHAR* pszUser)
  524. {
  525. BOOL bResult = TRUE;
  526. SAFEDELETE(m_pszUser);
  527. if(pszUser)
  528. {
  529. if (!CompareTokens(pszUser, CLI_TOKEN_NULL))
  530. {
  531. m_pszUser = new _TCHAR [lstrlen(pszUser)+1];
  532. if (m_pszUser)
  533. {
  534. lstrcpy(m_pszUser, pszUser);
  535. m_uConnInfoFlag |= USER;
  536. }
  537. else
  538. bResult = FALSE;
  539. }
  540. else
  541. m_uConnInfoFlag &= ~USER;
  542. }
  543. return bResult;
  544. }
  545. /*------------------------------------------------------------------------
  546. Name :SetPassword
  547. Synopsis :This function Assigns the password passed in parameter
  548. to m_pszPassword
  549. Type :Member Function
  550. Input parameters :
  551. pszPassword -Assigns the password passed in parameter to
  552. m_pszPassword
  553. Output parameters :None
  554. Return Type :BOOL
  555. Global Variables :None
  556. Calling Syntax :SetPassword(pszPassword)
  557. Notes :None
  558. ------------------------------------------------------------------------*/
  559. BOOL CGlobalSwitches::SetPassword(_TCHAR* pszPassword)
  560. {
  561. BOOL bResult = TRUE;
  562. SAFEDELETE(m_pszPassword)
  563. if (!CompareTokens(pszPassword, CLI_TOKEN_NULL))
  564. {
  565. m_pszPassword = new _TCHAR [lstrlen(pszPassword)+1];
  566. if (m_pszPassword)
  567. {
  568. lstrcpy(m_pszPassword, pszPassword);
  569. m_uConnInfoFlag |= PASSWORD;
  570. }
  571. else
  572. bResult = FALSE;
  573. }
  574. else
  575. m_uConnInfoFlag &= ~PASSWORD;
  576. return bResult;
  577. }
  578. /*------------------------------------------------------------------------
  579. Name :SetRecordPath(pszRecordPath)
  580. Synopsis :This function Assigns the record file passed in
  581. parameter to m_pszRecordPath
  582. Type :Member Function
  583. Input parameters :
  584. pszRecordPath -String type,contains Record path specified in the
  585. command.
  586. Output parameters :None
  587. Return Type :BOOL
  588. Global Variables :None
  589. Calling Syntax :SetRecordPath(pszRecordPath)
  590. Notes :None
  591. ------------------------------------------------------------------------*/
  592. BOOL CGlobalSwitches::SetRecordPath(_TCHAR* pszRecordPath)
  593. {
  594. BOOL bResult = TRUE;
  595. if (pszRecordPath)
  596. {
  597. // Check if the value specified is not _T("")
  598. if (!CompareTokens(pszRecordPath, CLI_TOKEN_NULL))
  599. {
  600. SAFEDELETE(m_pszRecordPath);
  601. m_pszRecordPath = new _TCHAR [lstrlen(pszRecordPath)+1];
  602. if (m_pszRecordPath)
  603. {
  604. lstrcpy(m_pszRecordPath, pszRecordPath);
  605. m_bRPChange = TRUE;
  606. }
  607. else
  608. bResult = FALSE;
  609. }
  610. // if the value specified is _T("") set the recordpath to NULL
  611. else
  612. {
  613. SAFEDELETE(m_pszRecordPath);
  614. m_bRPChange = TRUE;
  615. }
  616. }
  617. else
  618. {
  619. SAFEDELETE(m_pszRecordPath);
  620. m_bRPChange = TRUE;
  621. }
  622. return bResult;
  623. }
  624. /*------------------------------------------------------------------------
  625. Name :SetPrivileges(bEnable)
  626. Synopsis :This function sets bEnable flag to TRUE if Privileges
  627. :option is specified in the command
  628. Type :Member Function
  629. Input parameters :
  630. pszPrivileges -Boolean tye,Specifies whether the flag should be
  631. enabled or disabled
  632. Output parameters :None
  633. Return Type :None
  634. Global Variables :None
  635. Calling Syntax :SetPrivileges(pszPrivileges)
  636. Notes :None
  637. ------------------------------------------------------------------------*/
  638. void CGlobalSwitches::SetPrivileges(BOOL bEnable)
  639. {
  640. m_bPrivileges = bEnable;
  641. }
  642. /*------------------------------------------------------------------------
  643. Name :SetImpersonationLevel(_TCHAR* const pszImpLevel)
  644. Synopsis :This function checks whether the specified pszImpLevel
  645. is valid and assigns the mapped value to m_ImpLevel.
  646. Type :Member Function
  647. Input parameters :
  648. pszImpLevel - IMPLEVEL input string
  649. Output parameters :None
  650. Return Type :BOOL
  651. Global Variables :None
  652. Calling Syntax :SetImpersonationLevel(pszImpLevel)
  653. Notes :None
  654. ------------------------------------------------------------------------*/
  655. BOOL CGlobalSwitches::SetImpersonationLevel(_TCHAR* const pszImpLevel)
  656. {
  657. BOOL bResult = TRUE;
  658. // Check whether the string exists in the list of available values.
  659. CHARINTMAP::iterator theIterator = NULL;
  660. theIterator = m_cimImpLevel.find(CharUpper(pszImpLevel));
  661. if (theIterator != m_cimImpLevel.end())
  662. {
  663. m_ImpLevel = (IMPLEVEL) (*theIterator).second;
  664. }
  665. else
  666. bResult = FALSE;
  667. return bResult;
  668. }
  669. /*------------------------------------------------------------------------
  670. Name :SetAuthenticationLevel(_TCHAR* const pszAuthLevel)
  671. Synopsis :This function checks whether the specified pszAuthLevel
  672. is valid and assigns the mapped value to m_AuthLevel.
  673. Type :Member Function
  674. Input parameters :
  675. pszAuthLevel - AUTHLEVEL input string
  676. Output parameters :None
  677. Return Type :BOOL
  678. Global Variables :None
  679. Calling Syntax :SetAuthenticationLevel(pszAuthLevel)
  680. Notes :None
  681. ------------------------------------------------------------------------*/
  682. BOOL CGlobalSwitches::SetAuthenticationLevel(_TCHAR* const pszAuthLevel)
  683. {
  684. BOOL bResult = TRUE;
  685. // Check whether the string exists in the list of available values.
  686. CHARINTMAP::iterator theIterator = NULL;
  687. theIterator = m_cimAuthLevel.find(CharUpper(pszAuthLevel));
  688. if (theIterator != m_cimAuthLevel.end())
  689. {
  690. m_AuthLevel = (AUTHLEVEL) (*theIterator).second;
  691. }
  692. else
  693. bResult = FALSE;
  694. return bResult;
  695. }
  696. /*------------------------------------------------------------------------
  697. Name :SetTraceMode(BOOL bTrace)
  698. Synopsis :This function sets the m_bTrace to TRUE,If Trace mode
  699. is specified in the command
  700. Type :Member Function
  701. Input parameter :
  702. Trace -Boolean type,Specifies whether the trace mode
  703. has been set or not
  704. Output parameters :None
  705. Return Type :None
  706. Global Variables :None
  707. Calling Syntax :SetTraceMode(bTrace)
  708. Notes :None
  709. ------------------------------------------------------------------------*/
  710. void CGlobalSwitches::SetTraceMode(BOOL bTrace)
  711. {
  712. m_bTrace = bTrace;
  713. }
  714. /*------------------------------------------------------------------------
  715. Name :SetInteractiveMode
  716. Synopsis :This function sets the m_bInteractive to TRUE,If
  717. interactive mode is specified in the command
  718. Type :Member Function
  719. Input parameter :
  720. bInteractive -Boolean type,Specifies whether the interactive mode
  721. has been set or not
  722. Output parameters :None
  723. Return Type :void
  724. Global Variables :None
  725. Calling Syntax :SetInteractiveMode(bInteractive)
  726. Notes :None
  727. ------------------------------------------------------------------------*/
  728. void CGlobalSwitches::SetInteractiveMode(BOOL bInteractive)
  729. {
  730. m_bInteractive = bInteractive;
  731. }
  732. /*------------------------------------------------------------------------
  733. Name :SetHelpFlag
  734. Synopsis :sets the m_bHelp to TRUE, If /? is specified in the
  735. command
  736. Type :Member Function
  737. Input parameters :
  738. bHelp -BOOL type Specifies whether the helpflag has been
  739. set or not
  740. Output parameters :None
  741. Return Type :void
  742. Global Variables :None
  743. Calling Syntax :SetHelpFlag(bHelp)
  744. Notes :None
  745. ------------------------------------------------------------------------*/
  746. void CGlobalSwitches::SetHelpFlag(BOOL bHelp)
  747. {
  748. m_bHelp = bHelp;
  749. }
  750. /*------------------------------------------------------------------------
  751. Name :SetHelpOption
  752. Synopsis :This function specifies whether the help should
  753. be brief or full
  754. Type :Member Function
  755. Input parameters :
  756. helpOption -Specifies whether the help should be brief or full
  757. Output parameters :None
  758. Return Type :void
  759. Global Variables :None
  760. Calling Syntax :SetHelpOption(helpOption)
  761. Notes :None
  762. ------------------------------------------------------------------------*/
  763. void CGlobalSwitches::SetHelpOption(HELPOPTION helpOption)
  764. {
  765. m_HelpOption = helpOption;
  766. }
  767. /*------------------------------------------------------------------------
  768. Name :SetConnInfoFlag
  769. Synopsis :This function sets the Connection Info flag
  770. Type :Member Function
  771. Input parameter :
  772. uFlag - Unsigned int type
  773. Output parameters :None
  774. Return Type :void
  775. Global Variables :None
  776. Calling Syntax :SetConnInfoFlag(uFlag)
  777. Notes :None
  778. ------------------------------------------------------------------------*/
  779. void CGlobalSwitches::SetConnInfoFlag(UINT uFlag)
  780. {
  781. m_uConnInfoFlag = uFlag;
  782. }
  783. /*------------------------------------------------------------------------
  784. Name :GetConnInfoFlag
  785. Synopsis :This function returns the Connection Info flag
  786. Type :Member Function
  787. Input parameter :None
  788. Output parameters :None
  789. Return Type :UINT
  790. Global Variables :None
  791. Calling Syntax :GetConnInfoFlag()
  792. Notes :None
  793. ------------------------------------------------------------------------*/
  794. UINT CGlobalSwitches::GetConnInfoFlag()
  795. {
  796. return m_uConnInfoFlag;
  797. }
  798. /*------------------------------------------------------------------------
  799. Name :GetNameSpace
  800. Synopsis :This function Returns the string held in m_pszNameSpace
  801. Type :Member Function
  802. Input parameters :None
  803. Output parameters :None
  804. Return Type :_TCHAR*
  805. Global Variables :None
  806. Calling Syntax :GetNameSpace()
  807. Notes :None
  808. ------------------------------------------------------------------------*/
  809. _TCHAR* CGlobalSwitches::GetNameSpace()
  810. {
  811. return m_pszNameSpace;
  812. }
  813. /*------------------------------------------------------------------------
  814. Name :GetAuthority
  815. Synopsis :This function returns the string held in m_pszAuthority
  816. Type :Member Function
  817. Input parameters :None
  818. Output parameters :None
  819. Return Type :_TCHAR*
  820. Global Variables :None
  821. Calling Syntax :GetAuthority()
  822. Notes :None
  823. ------------------------------------------------------------------------*/
  824. _TCHAR* CGlobalSwitches::GetAuthority()
  825. {
  826. return m_pszAuthority;
  827. }
  828. /*------------------------------------------------------------------------
  829. Name :GetRole
  830. Synopsis :This function Returns the string held in m_pszRole
  831. Type :Member Function
  832. Input parameters :None
  833. Output parameters :None
  834. Return Type :_TCHAR*
  835. Global Variables :None
  836. Calling Syntax :GetRole()
  837. Notes :None
  838. ------------------------------------------------------------------------*/
  839. _TCHAR* CGlobalSwitches::GetRole()
  840. {
  841. return m_pszRole;
  842. }
  843. /*------------------------------------------------------------------------
  844. Name :GetLocale
  845. Synopsis :This function Returns the string held in m_pszLocale .
  846. Type :Member Function
  847. Input parameters :None
  848. Output parameters :None
  849. Return Type :_TCHR*
  850. Global Variables :None
  851. Calling Syntax :GetLocale()
  852. Notes :None
  853. ------------------------------------------------------------------------*/
  854. _TCHAR* CGlobalSwitches::GetLocale()
  855. {
  856. return m_pszLocale;
  857. }
  858. /*------------------------------------------------------------------------
  859. Name :GetNodesList
  860. Synopsis :This function Returns the vector held in m_cvNodesList
  861. Type :Member Function
  862. Input parameter :None
  863. Output parameters :None
  864. Return Type :CHARVECTOR&
  865. Global Variables :None
  866. Calling Syntax :GetNodesList()
  867. Notes :None
  868. ------------------------------------------------------------------------*/
  869. CHARVECTOR& CGlobalSwitches::GetNodesList()
  870. {
  871. return m_cvNodesList;
  872. }
  873. /*------------------------------------------------------------------------
  874. Name :GetUser
  875. Synopsis :This function Returns the string held in m_pszUser.
  876. Type :Member Function
  877. Input parameter :None
  878. Output parameters :None
  879. Return Type :_TCHAR*
  880. Global Variables :None
  881. Calling Syntax :GetUser()
  882. Notes :None
  883. ------------------------------------------------------------------------*/
  884. _TCHAR* CGlobalSwitches::GetUser()
  885. {
  886. return m_pszUser;
  887. }
  888. /*------------------------------------------------------------------------
  889. Name :GetPassword
  890. Synopsis :This function Returns the string held in m_pszPassword
  891. Type :Member Function
  892. Input parameters :None
  893. Output parameters :None
  894. Return Type :_TCHAR*
  895. Global Variables :None
  896. Calling Syntax :GetPassword()
  897. Notes :None
  898. ------------------------------------------------------------------------*/
  899. _TCHAR* CGlobalSwitches::GetPassword()
  900. {
  901. return m_pszPassword;
  902. }
  903. /*------------------------------------------------------------------------
  904. Name :GetRecordPath
  905. Synopsis :This function Returns the string held in m_pszRecordPath
  906. Type :Member Function
  907. Input parameter :None
  908. Output parameters :None
  909. Return Type :_TCHAR*
  910. Global Variables :None
  911. Calling Syntax :GetRecordPath()
  912. Notes :None
  913. ------------------------------------------------------------------------*/
  914. _TCHAR* CGlobalSwitches::GetRecordPath()
  915. {
  916. return m_pszRecordPath;
  917. }
  918. /*------------------------------------------------------------------------
  919. Name :GetPrivileges
  920. Synopsis :This function Returns BOOL value held in m_bPrivileges
  921. Type :Member Function
  922. Input parameter :None
  923. Output parameters :None
  924. Return Type :BOOL
  925. Global Variables :None
  926. Calling Syntax :GetPrivileges()
  927. Notes :None
  928. ------------------------------------------------------------------------*/
  929. BOOL CGlobalSwitches::GetPrivileges()
  930. {
  931. return m_bPrivileges;
  932. }
  933. /*------------------------------------------------------------------------
  934. Name :GetImpersonationLevel
  935. Synopsis :This function Returns impersonation level held
  936. in m_ImpLevel
  937. Type :Member Function
  938. Input parameter :None
  939. Output parameters :None
  940. Return Type :LONG
  941. Global Variables :None
  942. Calling Syntax :GetImpersonationLevel()
  943. Notes :None
  944. ------------------------------------------------------------------------*/
  945. LONG CGlobalSwitches::GetImpersonationLevel()
  946. {
  947. return m_ImpLevel;
  948. }
  949. /*------------------------------------------------------------------------
  950. Name :GetAuthenticationLevel
  951. Synopsis :This function Returns authentication level held in
  952. m_AuthLevel
  953. Type :Member Function
  954. Input parameter :None
  955. Output parameters :None
  956. Return Type :LONG
  957. Global Variables :None
  958. Calling Syntax :GetAuthenticationLevel()
  959. Notes :None
  960. ------------------------------------------------------------------------*/
  961. LONG CGlobalSwitches::GetAuthenticationLevel()
  962. {
  963. return m_AuthLevel;
  964. }
  965. /*------------------------------------------------------------------------
  966. Name :GetTraceStatus
  967. Synopsis :This function Returns trace status held in m_bTrace
  968. Type :Member Function
  969. Input parameter :None
  970. Output parameters :None
  971. Return Type :BOOL
  972. Global Variables :None
  973. Calling Syntax :GetTraceStatus()
  974. Notes :None
  975. ------------------------------------------------------------------------*/
  976. BOOL CGlobalSwitches::GetTraceStatus()
  977. {
  978. return m_bTrace;
  979. }
  980. /*------------------------------------------------------------------------
  981. Name :GetInteractiveStatus
  982. Synopsis :This function Returns interactive status held
  983. in m_bInteractive
  984. Type :Member Function
  985. Input parameter :None
  986. Output parameters :None
  987. Return Type :BOOL
  988. Global Variables :None
  989. Calling Syntax :GetInteractiveStatus()
  990. Notes :None
  991. ------------------------------------------------------------------------*/
  992. BOOL CGlobalSwitches::GetInteractiveStatus()
  993. {
  994. return m_bInteractive;
  995. }
  996. /*------------------------------------------------------------------------
  997. Name :GetHelpFlag
  998. Synopsis :This function Returns help flag held in m_bHelp
  999. Type :Member Function
  1000. Input parameter :None
  1001. Output parameters :None
  1002. Return Type :BOOL
  1003. Global Variables :None
  1004. Calling Syntax :GetHelpFlag()
  1005. Notes :None
  1006. ------------------------------------------------------------------------*/
  1007. BOOL CGlobalSwitches::GetHelpFlag()
  1008. {
  1009. return m_bHelp;
  1010. }
  1011. /*------------------------------------------------------------------------
  1012. Name :GetHelpOption
  1013. Synopsis :This function Returns help option held in m_bHelpOption
  1014. Type :Member Function
  1015. Input parameter :None
  1016. Output parameters :None
  1017. Return Type :HELPOPTION
  1018. Global Variables :None
  1019. Calling Syntax :GetHelpOption()
  1020. Notes :None
  1021. ------------------------------------------------------------------------*/
  1022. HELPOPTION CGlobalSwitches::GetHelpOption()
  1023. {
  1024. return m_HelpOption;
  1025. }
  1026. /*------------------------------------------------------------------------
  1027. Name :GetRoleFlag
  1028. Synopsis :This function returns the role flag value
  1029. Type :Member Function
  1030. Input parameter :None
  1031. Output parameters :None
  1032. Return Type :BOOL
  1033. True - /role changed recently.
  1034. False - no change in role till last command
  1035. Global Variables :None
  1036. Calling Syntax :GetRoleFlag()
  1037. Notes :None
  1038. ------------------------------------------------------------------------*/
  1039. BOOL CGlobalSwitches::GetRoleFlag()
  1040. {
  1041. return m_bRoleFlag;
  1042. }
  1043. /*-------------------------------------------------------------------------
  1044. Name :SetNameSpaceFlag
  1045. Synopsis :This function sets the NameSpace flag value
  1046. Type :Member Function
  1047. Input parameter :BOOL bNSFlag
  1048. Output parameters :None
  1049. Return Type :None
  1050. Global Variables :None
  1051. Calling Syntax :SetNameSpaceFlag(bNSFlag)
  1052. Notes :None
  1053. -------------------------------------------------------------------------*/
  1054. void CGlobalSwitches::SetNameSpaceFlag(BOOL bNSFlag)
  1055. {
  1056. m_bNSFlag = bNSFlag;
  1057. }
  1058. /*-------------------------------------------------------------------------
  1059. Name :SetRoleFlag
  1060. Synopsis :This function sets the Role flag value
  1061. Type :Member Function
  1062. Input parameter :BOOL bRoleFlag
  1063. Output parameters :None
  1064. Return Type :None
  1065. Global Variables :None
  1066. Calling Syntax :SetRoleFlag(bRoleFlag)
  1067. Notes :None
  1068. -------------------------------------------------------------------------*/
  1069. void CGlobalSwitches::SetRoleFlag(BOOL bRoleFlag)
  1070. {
  1071. m_bRoleFlag = bRoleFlag;
  1072. }
  1073. /*-------------------------------------------------------------------------
  1074. Name :SetLocaleFlag
  1075. Synopsis :This function sets the Locale flag value
  1076. Type :Member Function
  1077. Input parameter :BOOL bLocaleFlag
  1078. Output parameters :None
  1079. Return Type :None
  1080. Global Variables :None
  1081. Calling Syntax :SetLocaleFlag(bLocaleFlag)
  1082. Notes :None
  1083. -------------------------------------------------------------------------*/
  1084. void CGlobalSwitches::SetLocaleFlag(BOOL bLocaleFlag)
  1085. {
  1086. m_bLocaleFlag = bLocaleFlag;
  1087. }
  1088. /*------------------------------------------------------------------------
  1089. Name :GetNamespaceFlag
  1090. Synopsis :This function returns the namespace flag value
  1091. Type :Member Function
  1092. Input parameter :None
  1093. Output parameters :None
  1094. Return Type :BOOL
  1095. True - /namespace changed recently.
  1096. False - no change in namespace till last command
  1097. Global Variables :None
  1098. Calling Syntax :GetRoleFlag()
  1099. Notes :None
  1100. ------------------------------------------------------------------------*/
  1101. BOOL CGlobalSwitches::GetNameSpaceFlag()
  1102. {
  1103. return m_bNSFlag;
  1104. }
  1105. /*------------------------------------------------------------------------
  1106. Name :GetRPChangeStatus
  1107. Synopsis :This function returns the recordpath flag value
  1108. Type :Member Function
  1109. Input parameter :None
  1110. Output parameters :None
  1111. Return Type :BOOL
  1112. True - recordpath changed recently.
  1113. False - no change in recordpath till last command
  1114. Global Variables :None
  1115. Calling Syntax :GetRPChangeStatus()
  1116. Notes :None
  1117. ------------------------------------------------------------------------*/
  1118. BOOL CGlobalSwitches::GetRPChangeStatus()
  1119. {
  1120. return m_bRPChange;
  1121. }
  1122. /*-------------------------------------------------------------------------
  1123. Name :SetRPChangeStatus
  1124. Synopsis :This function sets the recordpath flag value
  1125. Type :Member Function
  1126. Input parameter :BOOL bStatus
  1127. Output parameters :None
  1128. Return Type :None
  1129. Global Variables :None
  1130. Calling Syntax :SetRPChangeStatus(bStatus)
  1131. Notes :None
  1132. -------------------------------------------------------------------------*/
  1133. void CGlobalSwitches::SetRPChangeStatus(BOOL bStatus)
  1134. {
  1135. m_bRPChange = bStatus;
  1136. }
  1137. /*------------------------------------------------------------------------
  1138. Name :GetLocaleFlag
  1139. Synopsis :This function returns the Locale flag value
  1140. Type :Member Function
  1141. Input parameter :None
  1142. Output parameters :None
  1143. Return Type :BOOL
  1144. True - /Locale changed recently.
  1145. False - no change in Locale till last command
  1146. Global Variables :None
  1147. Calling Syntax :GetLocaleFlag()
  1148. Notes :None
  1149. ------------------------------------------------------------------------*/
  1150. BOOL CGlobalSwitches::GetLocaleFlag()
  1151. {
  1152. return m_bLocaleFlag;
  1153. }
  1154. /*------------------------------------------------------------------------
  1155. Name :SetNode
  1156. Synopsis :This function Assigns the node passed in parameter
  1157. to m_pszNode
  1158. Type :Member Function
  1159. Input parameters :
  1160. pszNode -String type,contains Node option specified in the
  1161. command
  1162. Output parameters :None
  1163. Return Type :BOOL
  1164. Global Variables :None
  1165. Calling Syntax :SetNode(pszNode)
  1166. Notes :None
  1167. ------------------------------------------------------------------------*/
  1168. BOOL CGlobalSwitches::SetNode(_TCHAR* pszNode)
  1169. {
  1170. BOOL bResult = TRUE;
  1171. SAFEDELETE(m_pszNode);
  1172. if(pszNode)
  1173. {
  1174. if (!CompareTokens(pszNode, CLI_TOKEN_NULL))
  1175. {
  1176. m_pszNode = new _TCHAR [lstrlen(pszNode)+1];
  1177. if (m_pszNode)
  1178. {
  1179. lstrcpy(m_pszNode, pszNode);
  1180. m_uConnInfoFlag |= NODE;
  1181. }
  1182. else
  1183. bResult = FALSE;
  1184. }
  1185. else
  1186. // "." specifies current node
  1187. {
  1188. m_pszNode = new _TCHAR [lstrlen(m_pszNodeName)+1];
  1189. if (m_pszNode)
  1190. {
  1191. lstrcpy(m_pszNode, m_pszNodeName);
  1192. m_uConnInfoFlag &= ~NODE;
  1193. }
  1194. else
  1195. bResult = FALSE;
  1196. }
  1197. }
  1198. return bResult;
  1199. }
  1200. /*------------------------------------------------------------------------
  1201. Name :GetNode
  1202. Synopsis :This function Returns the string held in m_pszNode
  1203. Type :Member Function
  1204. Input parameter :None
  1205. Output parameters :None
  1206. Return Type :_TCHAR*
  1207. Global Variables :None
  1208. Calling Syntax :GetNode()
  1209. Notes :None
  1210. ------------------------------------------------------------------------*/
  1211. _TCHAR* CGlobalSwitches::GetNode()
  1212. {
  1213. return m_pszNode;
  1214. }
  1215. /*------------------------------------------------------------------------
  1216. Name :ClearNodesList
  1217. Synopsis :Clears the nodes list
  1218. Type :Member Function
  1219. Input parameter :None
  1220. Output parameters :None
  1221. Return Type :BOOL
  1222. Global Variables :None
  1223. Calling Syntax :ClearNodesList()
  1224. Notes :None
  1225. ------------------------------------------------------------------------*/
  1226. BOOL CGlobalSwitches::ClearNodesList()
  1227. {
  1228. BOOL bRet = TRUE;
  1229. CleanUpCharVector(m_cvNodesList);
  1230. if (!AddToNodesList(CLI_TOKEN_NULL))
  1231. bRet = FALSE;
  1232. return bRet;
  1233. }
  1234. /*------------------------------------------------------------------------
  1235. Name :SetAskForPassFlag
  1236. Synopsis :This function sets the askforpassword flag
  1237. Type :Member Function
  1238. Input parameter :bFlag
  1239. Output parameters :None
  1240. Return Type :BOOL
  1241. Global Variables :None
  1242. Calling Syntax :SetAskForPassFlag(bFlag)
  1243. Notes :None
  1244. ------------------------------------------------------------------------*/
  1245. void CGlobalSwitches::SetAskForPassFlag(BOOL bFlag)
  1246. {
  1247. m_bAskForPassFlag = bFlag;
  1248. }
  1249. /*------------------------------------------------------------------------
  1250. Name :GetAskForPassFlag
  1251. Synopsis :This function checks and returns TRUE if the user
  1252. has to be prompted for the password
  1253. Type :Member Function
  1254. Input parameter :None
  1255. Output parameters :None
  1256. Return Type :BOOL
  1257. Global Variables :None
  1258. Calling Syntax :GetAskForPassFlag()
  1259. Notes :None
  1260. ------------------------------------------------------------------------*/
  1261. BOOL CGlobalSwitches::GetAskForPassFlag()
  1262. {
  1263. return m_bAskForPassFlag;
  1264. }
  1265. /*------------------------------------------------------------------------
  1266. Name :GetGetPrivilegesTextDesc
  1267. Synopsis :This function checks and Returns the string
  1268. equivalent of the boolean value contained in
  1269. m_bPrivilges flag
  1270. Type :Member Function
  1271. Input parameter :None
  1272. Output parameters :
  1273. bstrPriv - privileges status string
  1274. Return Type :None
  1275. Global Variables :None
  1276. Calling Syntax :GetPrivilegesTextDesc()
  1277. Notes :None
  1278. ------------------------------------------------------------------------*/
  1279. void CGlobalSwitches::GetPrivilegesTextDesc(_bstr_t& bstrPriv)
  1280. {
  1281. try
  1282. {
  1283. if (m_bPrivileges)
  1284. bstrPriv = _bstr_t(CLI_TOKEN_ENABLE);
  1285. else
  1286. bstrPriv = _bstr_t(CLI_TOKEN_DISABLE);
  1287. }
  1288. catch(_com_error& e)
  1289. {
  1290. _com_issue_error(e.Error());
  1291. }
  1292. }
  1293. /*------------------------------------------------------------------------
  1294. Name :GetTraceTextDesc
  1295. Synopsis :This function checks and Returns the string
  1296. equivalent of the boolean value contained in
  1297. m_bTrace flag
  1298. Type :Member Function
  1299. Input parameter :None
  1300. Output parameters :
  1301. bstrTrace - trace status string
  1302. Return Type :None
  1303. Global Variables :None
  1304. Calling Syntax :GetTraceTextDesc(bstrTrace)
  1305. Notes :None
  1306. ------------------------------------------------------------------------*/
  1307. void CGlobalSwitches::GetTraceTextDesc(_bstr_t& bstrTrace)
  1308. {
  1309. try
  1310. {
  1311. if (m_bTrace)
  1312. bstrTrace = CLI_TOKEN_ON;
  1313. else
  1314. bstrTrace = CLI_TOKEN_OFF;
  1315. }
  1316. catch(_com_error& e)
  1317. {
  1318. _com_issue_error(e.Error());
  1319. }
  1320. }
  1321. /*------------------------------------------------------------------------
  1322. Name :GetInteractiveTextDesc
  1323. Synopsis :This function checks and Returns the string
  1324. equivalent of the boolean value contained in
  1325. m_bInteractive flag
  1326. Type :Member Function
  1327. Input parameter :None
  1328. Output parameters :
  1329. bstrInteractive - interactive status string
  1330. Return Type :void
  1331. Global Variables :None
  1332. Calling Syntax :GetInteractiveTextDesc(bstrInteractive)
  1333. Notes :None
  1334. ------------------------------------------------------------------------*/
  1335. void CGlobalSwitches::GetInteractiveTextDesc(_bstr_t& bstrInteractive)
  1336. {
  1337. try
  1338. {
  1339. if (m_bInteractive)
  1340. bstrInteractive = CLI_TOKEN_ON;
  1341. else
  1342. bstrInteractive = CLI_TOKEN_OFF;
  1343. }
  1344. catch(_com_error& e)
  1345. {
  1346. _com_issue_error(e.Error());
  1347. }
  1348. }
  1349. /*------------------------------------------------------------------------
  1350. Name :GetFailFastTextDesc
  1351. Synopsis :Return the string equivalent of the boolean value
  1352. contained in m_bFailFast flag.
  1353. Type :Member Function
  1354. Input parameter :None
  1355. Output parameters :
  1356. bstrFailFast - FailFast status string
  1357. Return Type :void
  1358. Global Variables :None
  1359. Calling Syntax :GetFailFastTextDesc(bstrFailFast)
  1360. Notes :None
  1361. ------------------------------------------------------------------------*/
  1362. void CGlobalSwitches::GetFailFastTextDesc(_bstr_t& bstrFailFast)
  1363. {
  1364. try
  1365. {
  1366. if (m_bFailFast)
  1367. bstrFailFast = CLI_TOKEN_ON;
  1368. else
  1369. bstrFailFast = CLI_TOKEN_OFF;
  1370. }
  1371. catch(_com_error& e)
  1372. {
  1373. _com_issue_error(e.Error());
  1374. }
  1375. }
  1376. /*------------------------------------------------------------------------
  1377. Name :GetImpLevelTextDesc
  1378. Synopsis :This function checks and Returns the string
  1379. equivalent of the boolean value contained in
  1380. m_ImpLevel flag
  1381. Type :Member Function
  1382. Input parameter :None
  1383. Output parameters :
  1384. bstrImpLevel - impersonation level description
  1385. Return Type :None
  1386. Global Variables :None
  1387. Calling Syntax :GetImpLevelTextDesc(bstrImpLevel)
  1388. Notes :None
  1389. ------------------------------------------------------------------------*/
  1390. void CGlobalSwitches::GetImpLevelTextDesc(_bstr_t& bstrImpLevel)
  1391. {
  1392. try
  1393. {
  1394. switch(m_ImpLevel)
  1395. {
  1396. case 1:
  1397. bstrImpLevel = L"ANONYMOUS";
  1398. break;
  1399. case 2:
  1400. bstrImpLevel = L"IDENTIFY";
  1401. break;
  1402. case 3:
  1403. bstrImpLevel = L"IMPERSONATE";
  1404. break;
  1405. case 4:
  1406. bstrImpLevel = L"DELEGATE";
  1407. break;
  1408. default:
  1409. bstrImpLevel = TOKEN_NA;
  1410. break;
  1411. }
  1412. }
  1413. catch(_com_error& e)
  1414. {
  1415. _com_issue_error(e.Error());
  1416. }
  1417. }
  1418. /*------------------------------------------------------------------------
  1419. Name :GetAuthLevelTextDesc
  1420. Synopsis :This function checks and Returns the string
  1421. equivalent of the boolean value contained in
  1422. m_AuthLevel flag
  1423. Type :Member Function
  1424. Input parameter :None
  1425. Output parameters :
  1426. bstrAuthLevel - authentication level description
  1427. Return Type :None
  1428. Global Variables :None
  1429. Calling Syntax :GetAuthLevelTextDesc(bstrAuthLevel)
  1430. Notes :None
  1431. ------------------------------------------------------------------------*/
  1432. void CGlobalSwitches::GetAuthLevelTextDesc(_bstr_t& bstrAuthLevel)
  1433. {
  1434. try
  1435. {
  1436. switch(m_AuthLevel)
  1437. {
  1438. case 0:
  1439. bstrAuthLevel = L"DEFAULT";
  1440. break;
  1441. case 1:
  1442. bstrAuthLevel = L"NONE";
  1443. break;
  1444. case 2:
  1445. bstrAuthLevel = L"CONNECT";
  1446. break;
  1447. case 3:
  1448. bstrAuthLevel = L"CALL";
  1449. break;
  1450. case 4:
  1451. bstrAuthLevel = L"PKT";
  1452. break;
  1453. case 5:
  1454. bstrAuthLevel = L"PKTINTEGRITY";
  1455. break;
  1456. case 6:
  1457. bstrAuthLevel = L"PKTPRIVACY";
  1458. break;
  1459. default:
  1460. bstrAuthLevel = TOKEN_NA;
  1461. break;
  1462. }
  1463. }
  1464. catch(_com_error& e)
  1465. {
  1466. _com_issue_error(e.Error());
  1467. }
  1468. }
  1469. /*------------------------------------------------------------------------
  1470. Name :GetNodeString
  1471. Synopsis :This function Returns the ',' separated node
  1472. string of the available nodes
  1473. Type :Member Function
  1474. Input parameter :None
  1475. Output parameters :
  1476. bstrNString - node string (comma separated)
  1477. Return Type :void
  1478. Global Variables :None
  1479. Calling Syntax :GetNodeString(bstrNSString)
  1480. Notes :None
  1481. ------------------------------------------------------------------------*/
  1482. void CGlobalSwitches::GetNodeString(_bstr_t& bstrNString)
  1483. {
  1484. try
  1485. {
  1486. CHARVECTOR::iterator theIterator;
  1487. if (m_cvNodesList.size() > 1)
  1488. {
  1489. theIterator = m_cvNodesList.begin();
  1490. // Move to next node
  1491. theIterator++;
  1492. while (theIterator != m_cvNodesList.end())
  1493. {
  1494. bstrNString += *theIterator;
  1495. theIterator++;
  1496. if (theIterator != m_cvNodesList.end())
  1497. bstrNString += L", ";
  1498. }
  1499. }
  1500. else
  1501. {
  1502. bstrNString = m_pszNode;
  1503. }
  1504. }
  1505. catch(_com_error& e)
  1506. {
  1507. _com_issue_error(e.Error());
  1508. }
  1509. }
  1510. /*------------------------------------------------------------------------
  1511. Name :GetRecordPathDesc
  1512. Synopsis :This function checks and Returns the string
  1513. equivalent of the boolean value contained in
  1514. m_pszRecordPath flag
  1515. Type :Member Function
  1516. Input parameter :None
  1517. Output parameters :
  1518. bstrRPDesc - record path description
  1519. Return Type :void
  1520. Global Variables :None
  1521. Calling Syntax :GetRecordPathDesc(bstrRPDesc)
  1522. Notes :None
  1523. ------------------------------------------------------------------------*/
  1524. void CGlobalSwitches::GetRecordPathDesc(_bstr_t& bstrRPDesc)
  1525. {
  1526. try
  1527. {
  1528. if (m_pszRecordPath)
  1529. {
  1530. bstrRPDesc = m_pszRecordPath;
  1531. }
  1532. else
  1533. bstrRPDesc = TOKEN_NA;
  1534. }
  1535. catch(_com_error& e)
  1536. {
  1537. _com_issue_error(e.Error());
  1538. }
  1539. }
  1540. /*------------------------------------------------------------------------
  1541. Name :SetFailFast
  1542. Synopsis :This function sets the m_bFailFast flag.
  1543. Type :Member Function
  1544. Input parameter :
  1545. bFlag - Boolean variable to set flag.
  1546. Output parameters :None
  1547. Return Type :void
  1548. Global Variables :None
  1549. Calling Syntax :SetFailFast(bFlag)
  1550. Notes :None
  1551. ------------------------------------------------------------------------*/
  1552. void CGlobalSwitches::SetFailFast(BOOL bFlag)
  1553. {
  1554. m_bFailFast = bFlag;
  1555. }
  1556. /*------------------------------------------------------------------------
  1557. Name :GetFailFast
  1558. Synopsis :This function returns the m_bFailFast flag.
  1559. Type :Member Function
  1560. Input parameter :None
  1561. Output parameters :None
  1562. Return Type :BOOL
  1563. Global Variables :None
  1564. Calling Syntax :GetFailFast()
  1565. Notes :None
  1566. ------------------------------------------------------------------------*/
  1567. BOOL CGlobalSwitches::GetFailFast()
  1568. {
  1569. return m_bFailFast;
  1570. }
  1571. /*------------------------------------------------------------------------
  1572. Name :SetOutputOption
  1573. Synopsis :This function sets the ouput option.
  1574. Type :Member Function
  1575. Input parameter :opoOutputOpt - Specifies the ouput option.
  1576. Output parameters :None
  1577. Return Type :void
  1578. Global Variables :None
  1579. Calling Syntax :SetOutputOption(opoOutputOpt)
  1580. Notes :None
  1581. ------------------------------------------------------------------------*/
  1582. void CGlobalSwitches::SetOutputOrAppendOption(OUTPUTSPEC opsOpt,
  1583. BOOL bIsOutput)
  1584. {
  1585. if ( bIsOutput == TRUE )
  1586. m_opsOutputOpt = opsOpt;
  1587. else
  1588. m_opsAppendOpt = opsOpt;
  1589. }
  1590. /*------------------------------------------------------------------------
  1591. Name :GetOutputOption
  1592. Synopsis :This function returns the ouput option.
  1593. Type :Member Function
  1594. Input parameter :None
  1595. Output parameters :None
  1596. Return Type :OUTPUTOPT
  1597. Global Variables :None
  1598. Calling Syntax :GetOutputOption()
  1599. Notes :None
  1600. ------------------------------------------------------------------------*/
  1601. OUTPUTSPEC CGlobalSwitches::GetOutputOrAppendOption(BOOL bIsOutput)
  1602. {
  1603. OUTPUTSPEC opsOpt;
  1604. if ( bIsOutput == TRUE )
  1605. opsOpt = m_opsOutputOpt;
  1606. else
  1607. opsOpt = m_opsAppendOpt;
  1608. return opsOpt;
  1609. }
  1610. /*------------------------------------------------------------------------
  1611. Name :SetOutputOrAppendFileName
  1612. Synopsis :This function Set Output or Append File Name,
  1613. bOutput = TRUE for Output FALSE for Append.
  1614. Type :Member Function
  1615. Input parameter :pszFileName - output or append file name
  1616. bOutput - output option
  1617. Output parameters :None
  1618. Return Type :BOOL
  1619. Global Variables :None
  1620. Calling Syntax :SetOutputOrAppendFileName(pszFileName,bOutput)
  1621. Notes :None
  1622. ------------------------------------------------------------------------*/
  1623. BOOL CGlobalSwitches::SetOutputOrAppendFileName(const _TCHAR* pszFileName,
  1624. BOOL bOutput)
  1625. {
  1626. BOOL bResult = TRUE;
  1627. if ( bOutput == TRUE )
  1628. {
  1629. SAFEDELETE(m_pszOutputFileName)
  1630. }
  1631. else
  1632. {
  1633. SAFEDELETE(m_pszAppendFileName)
  1634. }
  1635. if ( pszFileName != NULL )
  1636. {
  1637. _TCHAR* pszTempFileName;
  1638. pszTempFileName = new _TCHAR [lstrlen(pszFileName)+1];
  1639. if ( pszTempFileName == NULL )
  1640. bResult = FALSE;
  1641. else
  1642. {
  1643. if ( bOutput == TRUE )
  1644. {
  1645. m_pszOutputFileName = pszTempFileName;
  1646. lstrcpy(m_pszOutputFileName, pszFileName);
  1647. }
  1648. else
  1649. {
  1650. m_pszAppendFileName = pszTempFileName;
  1651. lstrcpy(m_pszAppendFileName, pszFileName);
  1652. }
  1653. }
  1654. }
  1655. return bResult;
  1656. }
  1657. /*------------------------------------------------------------------------
  1658. Name :GetOutputOrAppendFileName
  1659. Synopsis :This function returns the output or append file name
  1660. depending upon the output option - bOutput.
  1661. Input parameter :bOutput - output option
  1662. Output parameters :None
  1663. Return Type :_TCHAR
  1664. Global Variables :None
  1665. Calling Syntax :GetOutputOrAppendFileName(BOOL bOutput)
  1666. Notes :None
  1667. ------------------------------------------------------------------------*/
  1668. _TCHAR* CGlobalSwitches::GetOutputOrAppendFileName(BOOL bOutput)
  1669. {
  1670. _TCHAR* pszTempFile;
  1671. if ( bOutput == TRUE )
  1672. pszTempFile = m_pszOutputFileName;
  1673. else
  1674. pszTempFile = m_pszAppendFileName;
  1675. return pszTempFile;
  1676. }
  1677. /*------------------------------------------------------------------------
  1678. Name :GetOutputOptTextDesc
  1679. Synopsis :This function returns the string equivalent of the
  1680. OUTPUTOPT value contained in m_opoOutputOpt member.
  1681. Input parameter :None
  1682. Output parameters :bstrOutputOpt - string equivalent of the
  1683. OUTPUTOPT value
  1684. Return Type :void
  1685. Global Variables :None
  1686. Calling Syntax :GetOutputOptTextDesc(bstrOutputOpt)
  1687. Notes :None
  1688. ------------------------------------------------------------------------*/
  1689. void CGlobalSwitches::GetOutputOrAppendTextDesc(_bstr_t& bstrOutputOpt,
  1690. BOOL bIsOutput)
  1691. {
  1692. try
  1693. {
  1694. if ( bIsOutput == TRUE )
  1695. {
  1696. if ( m_opsOutputOpt == STDOUT )
  1697. bstrOutputOpt = CLI_TOKEN_STDOUT;
  1698. else if ( m_opsOutputOpt == CLIPBOARD )
  1699. bstrOutputOpt = CLI_TOKEN_CLIPBOARD;
  1700. else
  1701. bstrOutputOpt = _bstr_t(m_pszOutputFileName);
  1702. }
  1703. else
  1704. {
  1705. if ( m_opsAppendOpt == STDOUT )
  1706. bstrOutputOpt = CLI_TOKEN_STDOUT;
  1707. else if ( m_opsAppendOpt == CLIPBOARD )
  1708. bstrOutputOpt = CLI_TOKEN_CLIPBOARD;
  1709. else
  1710. bstrOutputOpt = _bstr_t(m_pszAppendFileName);
  1711. }
  1712. }
  1713. catch(_com_error& e)
  1714. {
  1715. _com_issue_error(e.Error());
  1716. }
  1717. }
  1718. /*------------------------------------------------------------------------
  1719. Name :SetOutputOrAppendFilePointer
  1720. Synopsis :This function Sets output or append file pointer,
  1721. bOutput == TRUE for Output
  1722. bOutput == FALSE or Append.
  1723. Input parameter :fpFile - pointer to output or append
  1724. bOutput - ouput option
  1725. Output parameters :None
  1726. Return Type :void
  1727. Global Variables :None
  1728. Calling Syntax :SetOutputOrAppendFilePointer(fpFile, bOutput)
  1729. Notes :None
  1730. ------------------------------------------------------------------------*/
  1731. void CGlobalSwitches::SetOutputOrAppendFilePointer(FILE* fpFile, BOOL bOutput)
  1732. {
  1733. if ( bOutput == TRUE )
  1734. m_fpOutFile = fpFile;
  1735. else
  1736. m_fpAppendFile = fpFile;
  1737. }
  1738. /*------------------------------------------------------------------------
  1739. Name :GetOutputOrAppendFilePointer
  1740. Synopsis :This function returns the ouput or append file pointer.
  1741. bOutput == TRUE for Output
  1742. bOutput == FALSE or Append.
  1743. Input parameter :bOutput - ouput option
  1744. Output parameters :None
  1745. Return Type :FILE*
  1746. Global Variables :None
  1747. Calling Syntax :GetOutputOrAppendFilePointer(bOutput)
  1748. Notes :None
  1749. ------------------------------------------------------------------------*/
  1750. FILE* CGlobalSwitches::GetOutputOrAppendFilePointer(BOOL bOutput)
  1751. {
  1752. FILE* fpTemp;
  1753. if ( bOutput == TRUE )
  1754. fpTemp = m_fpOutFile;
  1755. else
  1756. fpTemp = m_fpAppendFile;
  1757. return fpTemp;
  1758. }
  1759. /*------------------------------------------------------------------------
  1760. Name :GetSequenceNumber
  1761. Synopsis :This function returns the sequence number of the command
  1762. logged .
  1763. Input parameter :None
  1764. Output parameters :None
  1765. Return Type :WMICLIINT
  1766. Global Variables :None
  1767. Calling Syntax :GetSequenceNumber()
  1768. Notes :None
  1769. ------------------------------------------------------------------------*/
  1770. WMICLIINT CGlobalSwitches::GetSequenceNumber()
  1771. {
  1772. return m_nSeqNum;
  1773. }
  1774. /*------------------------------------------------------------------------
  1775. Name :GetLoggedonUser
  1776. Synopsis :This function returns the current logged on user.
  1777. Input parameter :None
  1778. Output parameters :None
  1779. Return Type :_TCHAR*
  1780. Global Variables :None
  1781. Calling Syntax :GetLoggedonUser()
  1782. Notes :None
  1783. ------------------------------------------------------------------------*/
  1784. _TCHAR* CGlobalSwitches::GetLoggedonUser()
  1785. {
  1786. return m_pszLoggedOnUser;
  1787. }
  1788. /*------------------------------------------------------------------------
  1789. Name :GetMgmtStationName
  1790. Synopsis :This function returns the management station that
  1791. issued the command.
  1792. Input parameter :None
  1793. Output parameters :None
  1794. Return Type :_TCHAR*
  1795. Global Variables :None
  1796. Calling Syntax :GetMgmtStationName()
  1797. Notes :None
  1798. ------------------------------------------------------------------------*/
  1799. _TCHAR* CGlobalSwitches::GetMgmtStationName()
  1800. {
  1801. return m_pszNodeName;
  1802. }
  1803. /*------------------------------------------------------------------------
  1804. Name :GetStartTime
  1805. Synopsis :This function returns the time at which the command
  1806. execution started.
  1807. Input parameter :None
  1808. Output parameters :None
  1809. Return Type :_TCHAR*
  1810. Global Variables :None
  1811. Calling Syntax :GetStartTime()
  1812. Notes :None
  1813. ------------------------------------------------------------------------*/
  1814. _TCHAR* CGlobalSwitches::GetStartTime()
  1815. {
  1816. return m_pszStartTime;
  1817. }
  1818. /*------------------------------------------------------------------------
  1819. Name :SetStartTime
  1820. Synopsis :This function sets the time at which the command
  1821. execution started.
  1822. Input parameter :None
  1823. Output parameters :None
  1824. Return Type :BOOL
  1825. Global Variables :None
  1826. Calling Syntax :SetStartTime()
  1827. Notes :None
  1828. ------------------------------------------------------------------------*/
  1829. BOOL CGlobalSwitches::SetStartTime()
  1830. {
  1831. BOOL bResult = TRUE;
  1832. if (m_pszStartTime == NULL)
  1833. {
  1834. m_pszStartTime = new _TCHAR[BUFFER64];
  1835. }
  1836. if (m_pszStartTime)
  1837. {
  1838. SYSTEMTIME stSysTime;
  1839. GetLocalTime(&stSysTime);
  1840. _stprintf(m_pszStartTime, L"%.2d-%.2d-%.4dT%.2d:%.2d:%.2d",
  1841. stSysTime.wMonth, stSysTime.wDay, stSysTime.wYear,
  1842. stSysTime.wHour, stSysTime.wMinute, stSysTime.wSecond);
  1843. // Increment the command counter.
  1844. m_nSeqNum++;
  1845. }
  1846. else
  1847. bResult = FALSE;
  1848. return bResult;
  1849. }
  1850. /*------------------------------------------------------------------------
  1851. Name :SetAggregateFlag
  1852. Synopsis :This function sets the Aggregation flag
  1853. Type :Member Function
  1854. Input parameter :None
  1855. Output parameters :None
  1856. Return Type :void
  1857. Global Variables :None
  1858. Calling Syntax :SetAggregateFlag(BOOL)
  1859. Notes :None
  1860. ------------------------------------------------------------------------*/
  1861. void CGlobalSwitches::SetAggregateFlag(BOOL bAggregateFlag)
  1862. {
  1863. m_bAggregateFlag = bAggregateFlag;
  1864. }
  1865. /*------------------------------------------------------------------------
  1866. Name :GetAggreagateFlag
  1867. Synopsis :This function gets the Aggregation flag
  1868. Type :Member Function
  1869. Input parameter :None
  1870. Output parameters :None
  1871. Return Type :BOOL
  1872. Global Variables :None
  1873. Calling Syntax :GetAggregateFlag()
  1874. Notes :None
  1875. ------------------------------------------------------------------------*/
  1876. BOOL CGlobalSwitches::GetAggregateFlag()
  1877. {
  1878. return m_bAggregateFlag;
  1879. }
  1880. /*------------------------------------------------------------------------
  1881. Name :GetAggregateTextDesc
  1882. Synopsis :This function checks and Returns the string
  1883. equivalent of the boolean value contained in
  1884. m_bAggregateFlag flag
  1885. Type :Member Function
  1886. Input parameter :None
  1887. Output parameters :
  1888. bstrAggregate - aggreaget status string
  1889. Return Type :None
  1890. Global Variables :None
  1891. Calling Syntax :GetAggregateTextDesc(bstrAggregate)
  1892. Notes :None
  1893. ------------------------------------------------------------------------*/
  1894. void CGlobalSwitches::GetAggregateTextDesc(_bstr_t& bstrAggregate)
  1895. {
  1896. try
  1897. {
  1898. if (m_bAggregateFlag)
  1899. bstrAggregate = CLI_TOKEN_ON;
  1900. else
  1901. bstrAggregate = CLI_TOKEN_OFF;
  1902. }
  1903. catch(_com_error& e)
  1904. {
  1905. _com_issue_error(e.Error());
  1906. }
  1907. }