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.

982 lines
28 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // PropList.h
  7. //
  8. // Implementation File:
  9. // PropList.cpp
  10. //
  11. // Description:
  12. // Definition of the CClusPropList class.
  13. //
  14. // Author:
  15. // <name> (<e-mail name>) Mmmm DD, 2002
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef __PROPLIST_H__
  23. #define __PROPLIST_H__
  24. #pragma once
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Include Files
  27. /////////////////////////////////////////////////////////////////////////////
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Forward Class Declarations
  30. /////////////////////////////////////////////////////////////////////////////
  31. class CObjectProperty;
  32. class CClusPropValueList;
  33. class CClusPropList;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // External Class Declarations
  36. /////////////////////////////////////////////////////////////////////////////
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Type Definitions
  39. /////////////////////////////////////////////////////////////////////////////
  40. #if !defined( ASSERT )
  41. #include <crtdbg.h>
  42. #define ASSERT _ASSERTE
  43. #endif // !defined( ASSERT )
  44. #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
  45. /////////////////////////////////////////////////////////////////////////////
  46. //++
  47. //
  48. // class CObjectProperty
  49. //
  50. // Description:
  51. // Describes a property in a cluster property list.
  52. //
  53. // Inheritance:
  54. // CObjectProperty
  55. //
  56. //--
  57. /////////////////////////////////////////////////////////////////////////////
  58. #if defined( __AFX_H__ ) || ( defined( __ATLTMP_H__ ) && !defined( _ATL_TMP_NO_CSTRING ) )
  59. class CObjectProperty
  60. {
  61. public:
  62. LPCWSTR m_pwszName;
  63. CLUSTER_PROPERTY_FORMAT m_propFormat;
  64. union CValue
  65. {
  66. CString * pstr;
  67. LONG * pl;
  68. DWORD * pdw;
  69. BOOL * pb;
  70. struct
  71. {
  72. PBYTE * ppb;
  73. DWORD * pcb;
  74. };
  75. };
  76. CValue m_value;
  77. CValue m_valuePrev;
  78. CValue m_valueEx; // expand_sz value (if any)
  79. DWORD m_fFlags;
  80. enum ObjPropFlags
  81. {
  82. opfNew = 1
  83. };
  84. CObjectProperty::CObjectProperty( void )
  85. {
  86. m_value.pstr = NULL;
  87. m_value.pcb = NULL;
  88. m_valuePrev.pstr = NULL;
  89. m_valuePrev.pcb = NULL;
  90. m_valueEx.pstr = NULL;
  91. m_valueEx.pcb = NULL;
  92. };
  93. void Set(
  94. IN LPCWSTR pwszName,
  95. IN CString & rstrValue,
  96. IN CString & rstrPrevValue,
  97. IN DWORD fFlags = 0
  98. )
  99. {
  100. m_pwszName = pwszName;
  101. m_propFormat = CLUSPROP_FORMAT_SZ;
  102. m_value.pstr = &rstrValue;
  103. m_valuePrev.pstr = &rstrPrevValue;
  104. m_fFlags = fFlags;
  105. } //*** Set( CString & )
  106. void SetExpandSz(
  107. IN LPCWSTR pwszName,
  108. IN CString & rstrValue,
  109. IN CString & rstrPrevValue,
  110. IN DWORD fFlags = 0
  111. )
  112. {
  113. m_pwszName = pwszName;
  114. m_propFormat = CLUSPROP_FORMAT_EXPAND_SZ;
  115. m_value.pstr = &rstrValue;
  116. m_valuePrev.pstr = &rstrPrevValue;
  117. m_fFlags = fFlags;
  118. } //*** Set( CString & )
  119. // Set() to get extra EXPANDED_SZ value
  120. void Set(
  121. IN LPCWSTR pwszName,
  122. IN CString & rstrValue,
  123. IN CString & rstrPrevValue,
  124. IN CString & rstrValueEx,
  125. IN DWORD fFlags = 0
  126. )
  127. {
  128. m_pwszName = pwszName;
  129. m_propFormat = CLUSPROP_FORMAT_SZ;
  130. m_value.pstr = &rstrValue;
  131. m_valuePrev.pstr = &rstrPrevValue;
  132. m_valueEx.pstr = &rstrValueEx;
  133. m_fFlags = fFlags;
  134. } //*** Set( CString & )
  135. // Set() to get extra EXPANDED_SZ value
  136. void SetExpandSz(
  137. IN LPCWSTR pwszName,
  138. IN CString & rstrValue,
  139. IN CString & rstrPrevValue,
  140. IN CString & rstrValueEx,
  141. IN DWORD fFlags = 0
  142. )
  143. {
  144. m_pwszName = pwszName;
  145. m_propFormat = CLUSPROP_FORMAT_EXPAND_SZ;
  146. m_value.pstr = &rstrValue;
  147. m_valuePrev.pstr = &rstrPrevValue;
  148. m_valueEx.pstr = &rstrValueEx;
  149. m_fFlags = fFlags;
  150. } //*** Set( CString & )
  151. void Set(
  152. IN LPCWSTR pwszName,
  153. IN LONG & rnValue,
  154. IN LONG & rnPrevValue,
  155. IN DWORD fFlags = 0
  156. )
  157. {
  158. m_pwszName = pwszName;
  159. m_propFormat = CLUSPROP_FORMAT_LONG;
  160. m_value.pl = &rnValue;
  161. m_valuePrev.pl = &rnPrevValue;
  162. m_fFlags = fFlags;
  163. } //*** Set( LONG & )
  164. void Set(
  165. IN LPCWSTR pwszName,
  166. IN DWORD & rdwValue,
  167. IN DWORD & rdwPrevValue,
  168. IN DWORD fFlags = 0
  169. )
  170. {
  171. m_pwszName = pwszName;
  172. m_propFormat = CLUSPROP_FORMAT_DWORD;
  173. m_value.pdw = &rdwValue;
  174. m_valuePrev.pdw = &rdwPrevValue;
  175. m_fFlags = fFlags;
  176. } //*** Set( DWORD & )
  177. void Set(
  178. IN LPCWSTR pwszName,
  179. IN BOOL & rbValue,
  180. IN BOOL & rbPrevValue,
  181. IN DWORD fFlags = 0
  182. )
  183. {
  184. m_pwszName = pwszName;
  185. m_propFormat = CLUSPROP_FORMAT_DWORD;
  186. m_value.pb = &rbValue;
  187. m_valuePrev.pb = &rbPrevValue;
  188. m_fFlags = fFlags;
  189. } //*** Set( BOOL & )
  190. void Set(
  191. IN LPCWSTR pwszName,
  192. IN PBYTE & rpbValue,
  193. IN DWORD & rcbValue,
  194. IN PBYTE & rpbPrevValue,
  195. IN DWORD & rcbPrevValue,
  196. IN DWORD fFlags = 0
  197. )
  198. {
  199. m_pwszName = pwszName;
  200. m_propFormat = CLUSPROP_FORMAT_BINARY;
  201. m_value.ppb = &rpbValue;
  202. m_value.pcb = &rcbValue;
  203. m_valuePrev.ppb = &rpbPrevValue;
  204. m_valuePrev.pcb = &rcbPrevValue;
  205. m_fFlags = fFlags;
  206. } //*** Set( PBYTE & )
  207. void Set(
  208. IN LPCWSTR pwszName,
  209. IN LPWSTR & rpwszValue,
  210. IN DWORD & rcbValue,
  211. IN LPWSTR & rpwszPrevValue,
  212. IN DWORD & rcbPrevValue,
  213. IN DWORD fFlags = 0
  214. )
  215. {
  216. m_pwszName = pwszName;
  217. m_propFormat = CLUSPROP_FORMAT_MULTI_SZ;
  218. m_value.ppb = reinterpret_cast< PBYTE * >( &rpwszValue );
  219. m_value.pcb = &rcbValue;
  220. m_valuePrev.ppb = reinterpret_cast< PBYTE * >( &rpwszPrevValue );
  221. m_valuePrev.pcb = &rcbPrevValue;
  222. m_fFlags = fFlags;
  223. } //*** Set( LPWSTR & )
  224. }; //*** class CObjectProperty
  225. #endif // defined( __AFX_H__ ) || ( defined( __ATLTMP_H__ ) && !defined( _ATL_TMP_NO_CSTRING ) )
  226. /////////////////////////////////////////////////////////////////////////////
  227. //++
  228. //
  229. // class CClusPropValueList
  230. //
  231. // Description:
  232. // Describes a cluster property list.
  233. //
  234. // Inheritance:
  235. // CClusPropValueList
  236. // CObject (MFC only)
  237. //
  238. //--
  239. /////////////////////////////////////////////////////////////////////////////
  240. class CClusPropValueList
  241. #ifdef __AFX_H__
  242. : public CObject
  243. #endif // __AFX_H__
  244. {
  245. #ifdef __AFX_H__
  246. DECLARE_DYNAMIC( CClusPropValueList );
  247. #endif // __AFX_H__
  248. public:
  249. //
  250. // Construction.
  251. //
  252. // Default constructor
  253. CClusPropValueList( void )
  254. : m_cbDataSize( 0 )
  255. , m_cbDataLeft( 0 )
  256. , m_cbBufferSize( 0 )
  257. , m_bAtEnd( FALSE )
  258. {
  259. m_cbhValueList.pb = NULL;
  260. m_cbhCurrentValue.pb = NULL;
  261. } //*** CClusPropValueList()
  262. // Copy constructor.
  263. CClusPropValueList( IN const CClusPropValueList & rcpvl )
  264. : m_cbBufferSize( 0 )
  265. , m_bAtEnd( FALSE )
  266. {
  267. Init( rcpvl );
  268. } //*** CClusPropValueList()
  269. // Buffer helper constructor.
  270. CClusPropValueList( IN CLUSPROP_BUFFER_HELPER cbhValueList, IN DWORD cbDataSize )
  271. : m_cbBufferSize( 0 )
  272. , m_bAtEnd( FALSE )
  273. {
  274. Init( cbhValueList, cbDataSize );
  275. } //*** CClusPropValueList()
  276. // Destructor
  277. ~CClusPropValueList( void )
  278. {
  279. DeleteValueList();
  280. } //*** ~CClusPropValueList()
  281. // Initialize the value list
  282. void Init( IN const CClusPropValueList & rcpvl )
  283. {
  284. ASSERT( m_cbBufferSize == 0 );
  285. m_cbhValueList = rcpvl.m_cbhValueList;
  286. m_cbhCurrentValue = rcpvl.m_cbhCurrentValue;
  287. m_cbDataSize = rcpvl.m_cbDataSize;
  288. m_cbDataLeft = rcpvl.m_cbDataLeft;
  289. m_bAtEnd = rcpvl.m_bAtEnd;
  290. } //*** Init()
  291. // Initialize the value list from a buffer helper
  292. void Init( IN const CLUSPROP_BUFFER_HELPER cbhValueList, IN DWORD cbDataSize )
  293. {
  294. ASSERT( m_cbBufferSize == 0 );
  295. m_cbhValueList = cbhValueList;
  296. m_cbhCurrentValue = cbhValueList;
  297. m_cbDataSize = cbDataSize;
  298. m_cbDataLeft = cbDataSize;
  299. m_bAtEnd = FALSE;
  300. } //*** Init()
  301. // Assignment operator
  302. void operator=( IN const CClusPropValueList & rcpvl )
  303. {
  304. ASSERT( m_cbBufferSize == 0 );
  305. m_cbhValueList = rcpvl.m_cbhValueList;
  306. m_cbhCurrentValue = rcpvl.m_cbhCurrentValue;
  307. m_cbDataSize = rcpvl.m_cbDataSize;
  308. m_cbDataLeft = rcpvl.m_cbDataLeft;
  309. m_bAtEnd = rcpvl.m_bAtEnd;
  310. } //*** operator=()
  311. public:
  312. //
  313. // Accessor methods.
  314. //
  315. // Buffer helper cast operator to access the current value
  316. operator const CLUSPROP_BUFFER_HELPER( void ) const
  317. {
  318. return m_cbhCurrentValue;
  319. } //*** operator CLUSPROP_BUFFER_HELPER()
  320. // Access the value list
  321. CLUSPROP_BUFFER_HELPER CbhValueList( void ) const
  322. {
  323. return m_cbhValueList;
  324. } //*** CbhValueList()
  325. // Access the current value
  326. CLUSPROP_BUFFER_HELPER CbhCurrentValue( void ) const
  327. {
  328. return m_cbhCurrentValue;
  329. } //*** CbhCurrentValue()
  330. // Access the format of the current value
  331. CLUSTER_PROPERTY_FORMAT CpfCurrentValueFormat( void ) const
  332. {
  333. return static_cast< CLUSTER_PROPERTY_FORMAT >( m_cbhCurrentValue.pValue->Syntax.wFormat );
  334. } //*** CpfCurrentValueFormat()
  335. // Access the type of the current value
  336. CLUSTER_PROPERTY_TYPE CptCurrentValueType( void ) const
  337. {
  338. return static_cast< CLUSTER_PROPERTY_TYPE >( m_cbhCurrentValue.pValue->Syntax.wType );
  339. } //*** CptCurrentValueType()
  340. // Access the syntax of the current value
  341. CLUSTER_PROPERTY_SYNTAX CpsCurrentValueSyntax( void ) const
  342. {
  343. return static_cast< CLUSTER_PROPERTY_SYNTAX >( m_cbhCurrentValue.pValue->Syntax.dw );
  344. } //*** CpsCurrentValueSyntax()
  345. // Access the length of the data of the current value
  346. DWORD CbCurrentValueLength( void ) const
  347. {
  348. DWORD cbLength;
  349. if ( m_cbhCurrentValue.pb == NULL )
  350. {
  351. cbLength = 0;
  352. } // if: no value list allocated yet
  353. else
  354. {
  355. cbLength = m_cbhCurrentValue.pValue->cbLength;
  356. } // else: value list allocated
  357. return cbLength;
  358. } //*** CbCurrentValueLength()
  359. // Access size of the data in the buffer.
  360. DWORD CbDataSize( void ) const
  361. {
  362. return m_cbDataSize;
  363. } //*** CbDataSize()
  364. // Access amount of data left in buffer after current value
  365. DWORD CbDataLeft( void ) const
  366. {
  367. return m_cbDataLeft;
  368. } //*** CbDataLeft()
  369. public:
  370. //
  371. // Parsing methods.
  372. //
  373. // Move to the first value in the list
  374. DWORD ScMoveToFirstValue( void );
  375. // Move the value after the current one in the list
  376. DWORD ScMoveToNextValue( void );
  377. // Query whether we are at the last value in the list or not
  378. DWORD ScCheckIfAtLastValue( void );
  379. public:
  380. //
  381. // Methods for building a value list.
  382. //
  383. // Allocate a value list
  384. DWORD ScAllocValueList( IN DWORD cbMinimum );
  385. // Delete the value list buffer and cleanup support variables
  386. void DeleteValueList( void )
  387. {
  388. //
  389. // If m_cbBufferSize is greater then 0 then we allocated the value list.
  390. // If it's zero then the value list is a part of the property list in
  391. // CClusPropList.
  392. //
  393. if ( m_cbBufferSize > 0 )
  394. {
  395. delete [] m_cbhValueList.pb;
  396. m_cbhValueList.pb = NULL;
  397. m_cbhCurrentValue.pb = NULL;
  398. m_cbBufferSize = 0;
  399. m_cbDataSize = 0;
  400. m_cbDataLeft = 0;
  401. m_bAtEnd = FALSE;
  402. } // if: we allocated anything
  403. } //*** DeletePropList()
  404. // Get a value list from a resource
  405. DWORD ScGetResourceValueList(
  406. IN HRESOURCE hResource,
  407. IN DWORD dwControlCode,
  408. IN HNODE hHostNode = NULL,
  409. IN LPVOID lpInBuffer = NULL,
  410. IN DWORD cbInBufferSize = 0
  411. );
  412. // Get a value list from a resource type
  413. DWORD ScGetResourceTypeValueList(
  414. IN HCLUSTER hCluster,
  415. IN LPCWSTR pwszResTypeName,
  416. IN DWORD dwControlCode,
  417. IN HNODE hHostNode = NULL,
  418. IN LPVOID lpInBuffer = NULL,
  419. IN DWORD cbInBufferSize = 0
  420. );
  421. private:
  422. CLUSPROP_BUFFER_HELPER m_cbhValueList; // Pointer to the value list for parsing.
  423. CLUSPROP_BUFFER_HELPER m_cbhCurrentValue; // Pointer to the current value for parsing.
  424. DWORD m_cbDataSize; // Amount of data in the buffer.
  425. DWORD m_cbDataLeft; // Amount of data left in buffer after current value.
  426. DWORD m_cbBufferSize; // Size of the buffer if we allocated it.
  427. BOOL m_bAtEnd; // Indicates whether at last value in list.
  428. }; //*** class CClusPropValueList
  429. /////////////////////////////////////////////////////////////////////////////
  430. //++
  431. //
  432. // class CClusPropList
  433. //
  434. // Description:
  435. // Describes a cluster property list.
  436. //
  437. // Inheritance:
  438. // CClusPropList
  439. // CObject (MFC only)
  440. //
  441. //--
  442. /////////////////////////////////////////////////////////////////////////////
  443. class CClusPropList
  444. #ifdef __AFX_H__
  445. : public CObject
  446. #endif // __AFX_H__
  447. {
  448. #ifdef __AFX_H__
  449. DECLARE_DYNAMIC( CClusPropList );
  450. #endif // __AFX_H__
  451. public:
  452. //
  453. // Construction.
  454. //
  455. // Default constructor
  456. CClusPropList( IN BOOL bAlwaysAddProp = FALSE )
  457. : m_bAlwaysAddProp( bAlwaysAddProp )
  458. , m_cbBufferSize( 0 )
  459. , m_cbDataSize( 0 )
  460. , m_cbDataLeft( 0 )
  461. , m_nPropsRemaining( 0 )
  462. {
  463. m_cbhPropList.pList = NULL;
  464. m_cbhCurrentProp.pb = NULL;
  465. m_cbhCurrentPropName.pb = NULL;
  466. } //*** CClusPropList()
  467. // Destructor
  468. ~CClusPropList( void )
  469. {
  470. DeletePropList();
  471. } //*** ~CClusPropList()
  472. // Copy list into this list (like assignment operator)
  473. DWORD ScCopy( IN const PCLUSPROP_LIST pcplPropList, IN DWORD cbListSize );
  474. // Delete the property list buffer and cleanup support variables
  475. void DeletePropList( void )
  476. {
  477. delete [] m_cbhPropList.pb;
  478. m_cbhPropList.pb = NULL;
  479. m_cbhCurrentProp.pb = NULL;
  480. m_cbhCurrentPropName.pb = NULL;
  481. m_cbBufferSize = 0;
  482. m_cbDataSize = 0;
  483. m_cbDataLeft = 0;
  484. } //*** DeletePropList()
  485. protected:
  486. //
  487. // Attributes.
  488. //
  489. BOOL m_bAlwaysAddProp; // Indicate if properties should be added even if not different.
  490. CLUSPROP_BUFFER_HELPER m_cbhPropList; // Pointer to the beginning of the list.
  491. CLUSPROP_BUFFER_HELPER m_cbhCurrentProp; // Pointer to the current property.
  492. DWORD m_cbBufferSize; // Allocated size of the buffer.
  493. DWORD m_cbDataSize; // Amount of data in the buffer.
  494. DWORD m_cbDataLeft; // Amount of data left in buffer after current value.
  495. private:
  496. CLUSPROP_BUFFER_HELPER m_cbhCurrentPropName; // Pointer to the current name for parsing
  497. DWORD m_nPropsRemaining; // Used by BMoveToNextProperty() to track end of list.
  498. CClusPropValueList m_pvlValues; // Helper class for value list of current property.
  499. public:
  500. //
  501. // Accessor methods.
  502. //
  503. // Access the values of the current property
  504. const CClusPropValueList & RPvlPropertyValue( void )
  505. {
  506. return m_pvlValues;
  507. } //*** RPvlPropertyValue()
  508. // Access the property list
  509. operator PCLUSPROP_LIST( void ) const
  510. {
  511. return m_cbhPropList.pList;
  512. } //*** operator PCLUSPROP_LIST()
  513. // Access allocated size of the buffer
  514. DWORD CbBufferSize( void ) const
  515. {
  516. return m_cbBufferSize;
  517. } //*** CbBufferSize()
  518. // Access the name of the current property
  519. LPCWSTR PszCurrentPropertyName( void ) const
  520. {
  521. return m_cbhCurrentPropName.pName->sz;
  522. } //*** PszCurrentPropertyName()
  523. // Access the current property name as a buffer helper
  524. const CLUSPROP_BUFFER_HELPER CbhCurrentPropertyName( void )
  525. {
  526. return m_cbhCurrentPropName;
  527. } //*** CbhCurrentPropertyName()
  528. // Access value list of the current property as a buffer helper
  529. const CLUSPROP_BUFFER_HELPER CbhCurrentValueList( void )
  530. {
  531. return m_pvlValues.CbhValueList();
  532. } //*** CbhCurrentValueList()
  533. // Access current value of the current property as a buffer helper
  534. const CLUSPROP_BUFFER_HELPER CbhCurrentValue( void )
  535. {
  536. return m_pvlValues.CbhCurrentValue();
  537. } //*** CbhCurrentValue()
  538. // Access the format of the current value of the current property
  539. CLUSTER_PROPERTY_FORMAT CpfCurrentValueFormat( void ) const
  540. {
  541. return m_pvlValues.CpfCurrentValueFormat();
  542. } //*** CpfCurrentValueFormat()
  543. // Access the type of the current value of the current property
  544. CLUSTER_PROPERTY_TYPE CptCurrentValueType( void ) const
  545. {
  546. return m_pvlValues.CptCurrentValueType();
  547. } //*** CptCurrentValueType()
  548. // Access the syntax of the current value of the current property
  549. CLUSTER_PROPERTY_SYNTAX CpsCurrentValueSyntax( void ) const
  550. {
  551. return m_pvlValues.CpsCurrentValueSyntax();
  552. } //*** CpsCurrentValueSyntax()
  553. // Access the length of the current value of the current property
  554. DWORD CbCurrentValueLength( void ) const
  555. {
  556. return m_pvlValues.CbCurrentValueLength();
  557. } //*** CbCurrentValueLength()
  558. PCLUSPROP_LIST Plist( void )
  559. {
  560. return m_cbhPropList.pList;
  561. } //*** Plist()
  562. const CLUSPROP_BUFFER_HELPER CbhPropList( void ) const
  563. {
  564. return m_cbhPropList;
  565. } //*** CbhPropList()
  566. PBYTE PbPropList( void ) const
  567. {
  568. return m_cbhPropList.pb;
  569. } //*** PbPropList()
  570. DWORD CbPropList( void ) const
  571. {
  572. return m_cbDataSize + sizeof( CLUSPROP_SYNTAX ); /*endmark*/
  573. } //*** CbPropList()
  574. // Access amount of data left in buffer after current value
  575. DWORD CbDataLeft( void ) const
  576. {
  577. return m_cbDataLeft;
  578. } //*** CbDataLeft()
  579. DWORD Cprops( void ) const
  580. {
  581. if ( m_cbhPropList.pb == NULL )
  582. {
  583. return 0;
  584. } // if: no buffer yet
  585. return m_cbhPropList.pList->nPropertyCount;
  586. } //*** Cprops()
  587. public:
  588. //
  589. // Parsing methods.
  590. //
  591. // Initialize the size after getting properties from an external source
  592. void InitSize( IN DWORD cbSize )
  593. {
  594. ASSERT( m_cbhPropList.pb != NULL );
  595. ASSERT( m_cbBufferSize > 0 );
  596. m_cbDataSize = cbSize;
  597. m_cbDataLeft = cbSize;
  598. } //*** InitSize()
  599. // Move to the first property in the list
  600. DWORD ScMoveToFirstProperty( void );
  601. // Move the property after the current one in the list
  602. DWORD ScMoveToNextProperty( void );
  603. // Move to a property by specifying its name
  604. DWORD ScMoveToPropertyByName( IN LPCWSTR pwszPropName );
  605. // Move to the first value in the current property
  606. DWORD ScMoveToFirstPropertyValue( void )
  607. {
  608. return m_pvlValues.ScMoveToFirstValue();
  609. } //*** ScMoveToFirstPropertyValue()
  610. // Move the the value after the current on in the current property
  611. DWORD ScMoveToNextPropertyValue( void )
  612. {
  613. return m_pvlValues.ScMoveToNextValue();
  614. } //*** ScMoveToNextPropertyValue()
  615. // Query whether we are at the last property in the list or not
  616. DWORD ScCheckIfAtLastProperty( void ) const
  617. {
  618. DWORD _sc;
  619. if ( m_nPropsRemaining <= 1 )
  620. {
  621. _sc = ERROR_NO_MORE_ITEMS;
  622. } // if: at the last property
  623. else
  624. {
  625. _sc = ERROR_SUCCESS;
  626. } // else: not at the last property
  627. return _sc;
  628. } //*** ScCheckIfAtLastProperty()
  629. // Query whether the list is empty or not
  630. BOOL BIsListEmpty( void ) const
  631. {
  632. ASSERT( m_cbhPropList.pb != NULL );
  633. ASSERT( m_cbDataSize >= sizeof( m_cbhPropList.pList->nPropertyCount ) );
  634. return m_cbhPropList.pList->nPropertyCount == 0;
  635. } //*** BIsListEmpty()
  636. public:
  637. //
  638. // Methods for building a property list.
  639. //
  640. // Allocate a property list
  641. DWORD ScAllocPropList( IN DWORD cbMinimum );
  642. void ClearPropList( void )
  643. {
  644. m_cbDataSize = 0;
  645. m_cbDataLeft = 0;
  646. if ( m_cbBufferSize != 0 )
  647. {
  648. ZeroMemory( m_cbhPropList.pb, m_cbBufferSize );
  649. m_cbhCurrentProp.pb = m_cbhPropList.pb + sizeof( m_cbhPropList.pList->nPropertyCount );
  650. m_cbhCurrentPropName = m_cbhCurrentProp;
  651. } // if: buffer already allocated
  652. } //*** ClearPropList()
  653. DWORD ScAddProp( IN LPCWSTR pwszName, IN LPCWSTR pwszValue, IN LPCWSTR pwszPrevValue );
  654. DWORD ScAddExpandSzProp( IN LPCWSTR pwszName, IN LPCWSTR pwszValue, IN LPCWSTR pwszPrevValue );
  655. DWORD ScAddMultiSzProp( IN LPCWSTR pwszName, IN LPCWSTR pwszValue, IN LPCWSTR pwszPrevValue );
  656. DWORD ScAddProp( IN LPCWSTR pwszName, IN DWORD nValue, IN DWORD nPrevValue );
  657. #if CLUSAPI_VERSION >= 0x0500
  658. DWORD ScAddProp( IN LPCWSTR pwszName, IN LONG nValue, IN LONG nPrevValue );
  659. #endif // CLUSAPI_VERSION >= 0x0500
  660. DWORD ScAddProp( IN LPCWSTR pwszName, IN ULONGLONG ullValue, IN ULONGLONG ullPrevValue );
  661. DWORD ScSetPropToDefault( IN LPCWSTR pwszName, IN CLUSTER_PROPERTY_FORMAT propfmt );
  662. DWORD ScAddProp(
  663. IN LPCWSTR pwszName,
  664. IN const PBYTE pbValue,
  665. IN DWORD cbValue,
  666. IN const PBYTE pbPrevValue,
  667. IN DWORD cbPrevValue
  668. );
  669. DWORD ScAddProp( IN LPCWSTR pwszName, IN LPCWSTR pwszValue )
  670. {
  671. return ScAddProp( pwszName, pwszValue, NULL );
  672. } //*** ScAddProp()
  673. DWORD ScAddExpandSzProp( IN LPCWSTR pwszName, IN LPCWSTR pwszValue )
  674. {
  675. return ScAddExpandSzProp( pwszName, pwszValue, NULL );
  676. } //*** ScAddExpandSzProp()
  677. public:
  678. //
  679. // Get Property methods.
  680. //
  681. DWORD ScGetNodeProperties(
  682. IN HNODE hNode,
  683. IN DWORD dwControlCode,
  684. IN HNODE hHostNode = NULL,
  685. IN LPVOID lpInBuffer = NULL,
  686. IN DWORD cbInBufferSize = 0
  687. );
  688. DWORD ScGetGroupProperties(
  689. IN HGROUP hGroup,
  690. IN DWORD dwControlCode,
  691. IN HNODE hHostNode = NULL,
  692. IN LPVOID lpInBuffer = NULL,
  693. IN DWORD cbInBufferSize = 0
  694. );
  695. DWORD ScGetResourceProperties(
  696. IN HRESOURCE hResource,
  697. IN DWORD dwControlCode,
  698. IN HNODE hHostNode = NULL,
  699. IN LPVOID lpInBuffer = NULL,
  700. IN DWORD cbInBufferSize = 0
  701. );
  702. DWORD ScGetResourceTypeProperties(
  703. IN HCLUSTER hCluster,
  704. IN LPCWSTR pwszResTypeName,
  705. IN DWORD dwControlCode,
  706. IN HNODE hHostNode = NULL,
  707. IN LPVOID lpInBuffer = NULL,
  708. IN DWORD cbInBufferSize = 0
  709. );
  710. DWORD ScGetNetworkProperties(
  711. IN HNETWORK hNetwork,
  712. IN DWORD dwControlCode,
  713. IN HNODE hHostNode = NULL,
  714. IN LPVOID lpInBuffer = NULL,
  715. IN DWORD cbInBufferSize = 0
  716. );
  717. DWORD ScGetNetInterfaceProperties(
  718. IN HNETINTERFACE hNetInterface,
  719. IN DWORD dwControlCode,
  720. IN HNODE hHostNode = NULL,
  721. IN LPVOID lpInBuffer = NULL,
  722. IN DWORD cbInBufferSize = 0
  723. );
  724. #if CLUSAPI_VERSION >= 0x0500
  725. DWORD ScGetClusterProperties(
  726. IN HCLUSTER hCluster,
  727. IN DWORD dwControlCode,
  728. IN HNODE hHostNode = NULL,
  729. IN LPVOID lpInBuffer = NULL,
  730. IN DWORD cbInBufferSize = 0
  731. );
  732. #endif // CLUSAPI_VERSION >= 0x0500
  733. // Implementation
  734. protected:
  735. void CopyProp(
  736. IN PCLUSPROP_SZ pprop,
  737. IN CLUSTER_PROPERTY_TYPE proptype,
  738. IN LPCWSTR psz,
  739. IN DWORD cbsz = 0
  740. );
  741. void CopyExpandSzProp(
  742. IN PCLUSPROP_SZ pprop,
  743. IN CLUSTER_PROPERTY_TYPE proptype,
  744. IN LPCWSTR psz,
  745. IN DWORD cbsz = 0
  746. );
  747. void CopyMultiSzProp(
  748. IN PCLUSPROP_MULTI_SZ pprop,
  749. IN CLUSTER_PROPERTY_TYPE proptype,
  750. IN LPCWSTR psz,
  751. IN DWORD cbsz = 0
  752. );
  753. void CopyProp(
  754. IN PCLUSPROP_DWORD pprop,
  755. IN CLUSTER_PROPERTY_TYPE proptype,
  756. IN DWORD nValue
  757. );
  758. #if CLUSAPI_VERSION >= 0x0500
  759. void CopyProp(
  760. IN PCLUSPROP_LONG pprop,
  761. IN CLUSTER_PROPERTY_TYPE proptype,
  762. IN LONG nValue
  763. );
  764. #endif // CLUSAPI_VERSION >= 0x0500
  765. void CopyProp(
  766. OUT PCLUSPROP_ULARGE_INTEGER pprop,
  767. IN CLUSTER_PROPERTY_TYPE proptype,
  768. IN ULONGLONG nValue
  769. );
  770. void CopyProp(
  771. IN PCLUSPROP_BINARY pprop,
  772. IN CLUSTER_PROPERTY_TYPE proptype,
  773. IN const PBYTE pb,
  774. IN DWORD cb
  775. );
  776. void CopyEmptyProp(
  777. IN PCLUSPROP_VALUE pprop,
  778. IN CLUSTER_PROPERTY_TYPE proptype,
  779. IN CLUSTER_PROPERTY_FORMAT propfmt
  780. );
  781. }; //*** class CClusPropList
  782. #pragma warning( default : 4201 )
  783. /////////////////////////////////////////////////////////////////////////////
  784. #endif // __PROPLIST_H__