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.

1013 lines
30 KiB

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