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.

991 lines
23 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997-1999 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. // David Potter (davidp) February 24, 1997
  16. //
  17. // Revision History:
  18. // 12/18/1998 GalenB Added MoveFirst, MoveNext, and other parsing
  19. // methods.
  20. //
  21. // Notes:
  22. //
  23. /////////////////////////////////////////////////////////////////////////////
  24. #ifndef _PROPLIST_H_
  25. #define _PROPLIST_H_
  26. #pragma once
  27. #include <clusapi.h>
  28. #include <resapi.h>
  29. /////////////////////////////////////////////////////////////////////////////
  30. // Include Files
  31. /////////////////////////////////////////////////////////////////////////////
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Forward Class Declarations
  34. /////////////////////////////////////////////////////////////////////////////
  35. class CObjectProperty;
  36. class CClusPropValueList;
  37. class CClusPropList;
  38. /////////////////////////////////////////////////////////////////////////////
  39. // External Class Declarations
  40. /////////////////////////////////////////////////////////////////////////////
  41. /////////////////////////////////////////////////////////////////////////////
  42. // Type Definitions
  43. /////////////////////////////////////////////////////////////////////////////
  44. #if !defined( ASSERT )
  45. #include <crtdbg.h>
  46. #define ASSERT _ASSERTE
  47. #endif // !defined( ASSERT )
  48. #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
  49. /////////////////////////////////////////////////////////////////////////////
  50. //++
  51. //
  52. // class CObjectProperty
  53. //
  54. // Description:
  55. // Describes a property in a cluster property list.
  56. //
  57. // Inheritance:
  58. // CObjectProperty
  59. //
  60. //--
  61. /////////////////////////////////////////////////////////////////////////////
  62. #if defined( __AFX_H__ ) || ( defined( __ATLTMP_H__ ) && !defined( _ATL_TMP_NO_CSTRING ) )
  63. class CObjectProperty
  64. {
  65. public:
  66. LPCWSTR m_pwszName;
  67. CLUSTER_PROPERTY_FORMAT m_propFormat;
  68. union CValue
  69. {
  70. CString * pstr;
  71. LONG * pl;
  72. DWORD * pdw;
  73. BOOL * pb;
  74. struct
  75. {
  76. PBYTE * ppb;
  77. DWORD * pcb;
  78. };
  79. };
  80. CValue m_value;
  81. CValue m_valuePrev;
  82. CValue m_valueEx; // expand_sz value (if any)
  83. DWORD m_fFlags;
  84. enum ObjPropFlags
  85. {
  86. opfNew = 1
  87. };
  88. CObjectProperty::CObjectProperty( void )
  89. {
  90. m_value.pstr = NULL;
  91. m_value.pcb = NULL;
  92. m_valuePrev.pstr = NULL;
  93. m_valuePrev.pcb = NULL;
  94. m_valueEx.pstr = NULL;
  95. m_valueEx.pcb = NULL;
  96. };
  97. void Set(
  98. IN LPCWSTR pwszName,
  99. IN CString & rstrValue,
  100. IN CString & rstrPrevValue,
  101. IN DWORD fFlags = 0
  102. )
  103. {
  104. m_pwszName = pwszName;
  105. m_propFormat = CLUSPROP_FORMAT_SZ;
  106. m_value.pstr = &rstrValue;
  107. m_valuePrev.pstr = &rstrPrevValue;
  108. m_fFlags = fFlags;
  109. } //*** Set( CString & )
  110. void SetExpandSz(
  111. IN LPCWSTR pwszName,
  112. IN CString & rstrValue,
  113. IN CString & rstrPrevValue,
  114. IN DWORD fFlags = 0
  115. )
  116. {
  117. m_pwszName = pwszName;
  118. m_propFormat = CLUSPROP_FORMAT_EXPAND_SZ;
  119. m_value.pstr = &rstrValue;
  120. m_valuePrev.pstr = &rstrPrevValue;
  121. m_fFlags = fFlags;
  122. } //*** Set( CString & )
  123. // Set() to get extra EXPANDED_SZ value
  124. void Set(
  125. IN LPCWSTR pwszName,
  126. IN CString & rstrValue,
  127. IN CString & rstrPrevValue,
  128. IN CString & rstrValueEx,
  129. IN DWORD fFlags = 0
  130. )
  131. {
  132. m_pwszName = pwszName;
  133. m_propFormat = CLUSPROP_FORMAT_SZ;
  134. m_value.pstr = &rstrValue;
  135. m_valuePrev.pstr = &rstrPrevValue;
  136. m_valueEx.pstr = &rstrValueEx;
  137. m_fFlags = fFlags;
  138. } //*** Set( CString & )
  139. // Set() to get extra EXPANDED_SZ value
  140. void SetExpandSz(
  141. IN LPCWSTR pwszName,
  142. IN CString & rstrValue,
  143. IN CString & rstrPrevValue,
  144. IN CString & rstrValueEx,
  145. IN DWORD fFlags = 0
  146. )
  147. {
  148. m_pwszName = pwszName;
  149. m_propFormat = CLUSPROP_FORMAT_EXPAND_SZ;
  150. m_value.pstr = &rstrValue;
  151. m_valuePrev.pstr = &rstrPrevValue;
  152. m_valueEx.pstr = &rstrValueEx;
  153. m_fFlags = fFlags;
  154. } //*** Set( CString & )
  155. void Set(
  156. IN LPCWSTR pwszName,
  157. IN LONG & rnValue,
  158. IN LONG & rnPrevValue,
  159. IN DWORD fFlags = 0
  160. )
  161. {
  162. m_pwszName = pwszName;
  163. m_propFormat = CLUSPROP_FORMAT_LONG;
  164. m_value.pl = &rnValue;
  165. m_valuePrev.pl = &rnPrevValue;
  166. m_fFlags = fFlags;
  167. } //*** Set( LONG & )
  168. void Set(
  169. IN LPCWSTR pwszName,
  170. IN DWORD & rdwValue,
  171. IN DWORD & rdwPrevValue,
  172. IN DWORD fFlags = 0
  173. )
  174. {
  175. m_pwszName = pwszName;
  176. m_propFormat = CLUSPROP_FORMAT_DWORD;
  177. m_value.pdw = &rdwValue;
  178. m_valuePrev.pdw = &rdwPrevValue;
  179. m_fFlags = fFlags;
  180. } //*** Set( DWORD & )
  181. void Set(
  182. IN LPCWSTR pwszName,
  183. IN BOOL & rbValue,
  184. IN BOOL & rbPrevValue,
  185. IN DWORD fFlags = 0
  186. )
  187. {
  188. m_pwszName = pwszName;
  189. m_propFormat = CLUSPROP_FORMAT_DWORD;
  190. m_value.pb = &rbValue;
  191. m_valuePrev.pb = &rbPrevValue;
  192. m_fFlags = fFlags;
  193. } //*** Set( BOOL & )
  194. void Set(
  195. IN LPCWSTR pwszName,
  196. IN PBYTE & rpbValue,
  197. IN DWORD & rcbValue,
  198. IN PBYTE & rpbPrevValue,
  199. IN DWORD & rcbPrevValue,
  200. IN DWORD fFlags = 0
  201. )
  202. {
  203. m_pwszName = pwszName;
  204. m_propFormat = CLUSPROP_FORMAT_BINARY;
  205. m_value.ppb = &rpbValue;
  206. m_value.pcb = &rcbValue;
  207. m_valuePrev.ppb = &rpbPrevValue;
  208. m_valuePrev.pcb = &rcbPrevValue;
  209. m_fFlags = fFlags;
  210. } //*** Set( PBYTE & )
  211. void Set(
  212. IN LPCWSTR pwszName,
  213. IN LPWSTR & rpwszValue,
  214. IN DWORD & rcbValue,
  215. IN LPWSTR & rpwszPrevValue,
  216. IN DWORD & rcbPrevValue,
  217. IN DWORD fFlags = 0
  218. )
  219. {
  220. m_pwszName = pwszName;
  221. m_propFormat = CLUSPROP_FORMAT_MULTI_SZ;
  222. m_value.ppb = reinterpret_cast< PBYTE * >( &rpwszValue );
  223. m_value.pcb = &rcbValue;
  224. m_valuePrev.ppb = reinterpret_cast< PBYTE * >( &rpwszPrevValue );
  225. m_valuePrev.pcb = &rcbPrevValue;
  226. m_fFlags = fFlags;
  227. } //*** Set( LPWSTR & )
  228. }; //*** class CObjectProperty
  229. #endif // defined( __AFX_H__ ) || ( defined( __ATLTMP_H__ ) && !defined( _ATL_TMP_NO_CSTRING ) )
  230. class CClusPropValueList
  231. #ifdef __AFX_H__
  232. : public CObject
  233. #endif // __AFX_H__
  234. {
  235. #ifdef __AFX_H__
  236. DECLARE_DYNAMIC( CClusPropValueList );
  237. #endif // __AFX_H__
  238. public:
  239. //
  240. // Construction.
  241. //
  242. // Default constructor
  243. CClusPropValueList( void )
  244. : m_cbDataSize( 0 )
  245. , m_cbDataLeft( 0 )
  246. , m_cbBufferSize( 0 )
  247. , m_bAtEnd( FALSE )
  248. {
  249. m_cbhValueList.pb = NULL;
  250. m_cbhCurrentValue.pb = NULL;
  251. } //*** CClusPropValueList()
  252. // Copy constructor.
  253. CClusPropValueList( IN const CClusPropValueList & rcpvl )
  254. : m_cbBufferSize( 0 )
  255. , m_bAtEnd( FALSE )
  256. {
  257. Init( rcpvl );
  258. } //*** CClusPropValueList()
  259. // Buffer helper constructor.
  260. CClusPropValueList( IN CLUSPROP_BUFFER_HELPER cbhValueList, IN DWORD cbDataSize )
  261. : m_cbBufferSize( 0 )
  262. , m_bAtEnd( FALSE )
  263. {
  264. Init( cbhValueList, cbDataSize );
  265. } //*** CClusPropValueList()
  266. // Destructor
  267. ~CClusPropValueList( void )
  268. {
  269. DeleteValueList();
  270. } //*** ~CClusPropValueList()
  271. // Initialize the value list
  272. void Init( IN const CClusPropValueList & rcpvl )
  273. {
  274. ASSERT( m_cbBufferSize == 0 );
  275. m_cbhValueList = rcpvl.m_cbhValueList;
  276. m_cbhCurrentValue = rcpvl.m_cbhCurrentValue;
  277. m_cbDataSize = rcpvl.m_cbDataSize;
  278. m_cbDataLeft = rcpvl.m_cbDataLeft;
  279. m_bAtEnd = rcpvl.m_bAtEnd;
  280. } //*** Init()
  281. // Initialize the value list from a buffer helper
  282. void Init( IN const CLUSPROP_BUFFER_HELPER cbhValueList, IN DWORD cbDataSize )
  283. {
  284. ASSERT( m_cbBufferSize == 0 );
  285. m_cbhValueList = cbhValueList;
  286. m_cbhCurrentValue = cbhValueList;
  287. m_cbDataSize = cbDataSize;
  288. m_cbDataLeft = cbDataSize;
  289. m_bAtEnd = FALSE;
  290. } //*** Init()
  291. // Assignment operator
  292. void operator=( IN const CClusPropValueList & rcpvl )
  293. {
  294. ASSERT( m_cbBufferSize == 0 );
  295. m_cbhValueList = rcpvl.m_cbhValueList;
  296. m_cbhCurrentValue = rcpvl.m_cbhCurrentValue;
  297. m_cbDataSize = rcpvl.m_cbDataSize;
  298. m_cbDataLeft = rcpvl.m_cbDataLeft;
  299. m_bAtEnd = rcpvl.m_bAtEnd;
  300. } //*** operator=()
  301. public:
  302. //
  303. // Accessor methods.
  304. //
  305. // Buffer helper cast operator to access the current value
  306. operator const CLUSPROP_BUFFER_HELPER( void ) const
  307. {
  308. return m_cbhCurrentValue;
  309. } //*** operator CLUSPROP_BUFFER_HELPER()
  310. // Access the value list
  311. CLUSPROP_BUFFER_HELPER CbhValueList( void ) const
  312. {
  313. return m_cbhValueList;
  314. } //*** CbhValueList()
  315. // Access the current value
  316. CLUSPROP_BUFFER_HELPER CbhCurrentValue( void ) const
  317. {
  318. return m_cbhCurrentValue;
  319. } //*** CbhCurrentValue()
  320. // Access the format of the current value
  321. CLUSTER_PROPERTY_FORMAT CpfCurrentValueFormat( void ) const
  322. {
  323. return static_cast< CLUSTER_PROPERTY_FORMAT >( m_cbhCurrentValue.pValue->Syntax.wFormat );
  324. } //*** CpfCurrentValueFormat()
  325. // Access the format of the current format list syntax entry
  326. CLUSTER_PROPERTY_FORMAT CpfCurrentFormatListSyntax( void ) const
  327. {
  328. return static_cast< CLUSTER_PROPERTY_FORMAT >( m_cbhCurrentValue.pWordValue->w );
  329. } //*** CpfCurrentFormatListSyntax()
  330. // Access the type of the current value
  331. CLUSTER_PROPERTY_TYPE CptCurrentValueType( void ) const
  332. {
  333. return static_cast< CLUSTER_PROPERTY_TYPE >( m_cbhCurrentValue.pValue->Syntax.wType );
  334. } //*** CptCurrentValueType()
  335. // Access the syntax of the current value
  336. CLUSTER_PROPERTY_SYNTAX CpsCurrentValueSyntax( void ) const
  337. {
  338. return static_cast< CLUSTER_PROPERTY_SYNTAX >( m_cbhCurrentValue.pValue->Syntax.dw );
  339. } //*** CpsCurrentValueSyntax()
  340. // Access the length of the data of the current value
  341. DWORD CbCurrentValueLength( void ) const
  342. {
  343. DWORD cbLength;
  344. if ( m_cbhCurrentValue.pb == NULL )
  345. {
  346. cbLength = 0;
  347. } // if: no value list allocated yet
  348. else
  349. {
  350. cbLength = m_cbhCurrentValue.pValue->cbLength;
  351. } // else: value list allocated
  352. return cbLength;
  353. } //*** CbCurrentValueLength()
  354. // Access size of the data in the buffer.
  355. DWORD CbDataSize( void ) const
  356. {
  357. return m_cbDataSize;
  358. } //*** CbDataSize()
  359. // Access amount of data left in buffer after current value
  360. DWORD CbDataLeft( void ) const
  361. {
  362. return m_cbDataLeft;
  363. } //*** CbDataLeft()
  364. public:
  365. //
  366. // Parsing methods.
  367. //
  368. // Move to the first value in the list
  369. DWORD ScMoveToFirstValue( void );
  370. // Move the value after the current one in the list
  371. DWORD ScMoveToNextValue( void );
  372. // Query whether we are at the last value in the list or not
  373. DWORD ScCheckIfAtLastValue( void );
  374. public:
  375. //
  376. // Methods for building a value list.
  377. //
  378. // Allocate a value list
  379. DWORD ScAllocValueList( IN DWORD cbMinimum );
  380. // Delete the value list buffer and cleanup support variables
  381. void DeleteValueList( void )
  382. {
  383. //
  384. // If m_cbBufferSize is greater then 0 then we allocated the value list.
  385. // If it's zero then the value list is a part of the property list in
  386. // CClusPropList.
  387. //
  388. if ( m_cbBufferSize > 0 )
  389. {
  390. delete [] m_cbhValueList.pb;
  391. m_cbhValueList.pb = NULL;
  392. m_cbhCurrentValue.pb = NULL;
  393. m_cbBufferSize = 0;
  394. m_cbDataSize = 0;
  395. m_cbDataLeft = 0;
  396. m_bAtEnd = FALSE;
  397. } // if: we allocated anything
  398. } //*** DeletePropList()
  399. // Get a value list from a resource
  400. DWORD ScGetResourceValueList(
  401. IN HRESOURCE hResource,
  402. IN DWORD dwControlCode,
  403. IN HNODE hHostNode = NULL,
  404. IN LPVOID lpInBuffer = NULL,
  405. IN DWORD cbInBufferSize = 0
  406. );
  407. // Get a value list from a resource type
  408. DWORD ScGetResourceTypeValueList(
  409. IN HCLUSTER hCluster,
  410. IN LPCWSTR pwszResTypeName,
  411. IN DWORD dwControlCode,
  412. IN HNODE hHostNode = NULL,
  413. IN LPVOID lpInBuffer = NULL,
  414. IN DWORD cbInBufferSize = 0
  415. );
  416. private:
  417. CLUSPROP_BUFFER_HELPER m_cbhValueList; // Pointer to the value list for parsing.
  418. CLUSPROP_BUFFER_HELPER m_cbhCurrentValue; // Pointer to the current value for parsing.
  419. DWORD m_cbDataSize; // Amount of data in the buffer.
  420. DWORD m_cbDataLeft; // Amount of data left in buffer after current value.
  421. DWORD m_cbBufferSize; // Size of the buffer if we allocated it.
  422. BOOL m_bAtEnd; // Indicates whether at last value in list.
  423. }; //*** class CClusPropValueList
  424. /////////////////////////////////////////////////////////////////////////////
  425. //++
  426. //
  427. // class CClusPropList
  428. //
  429. // Description:
  430. // Describes a cluster property list.
  431. //
  432. // Inheritance:
  433. // CClusPropList
  434. // CObject (MFC only)
  435. //
  436. //--
  437. /////////////////////////////////////////////////////////////////////////////
  438. class CClusPropList
  439. #ifdef __AFX_H__
  440. : public CObject
  441. #endif // __AFX_H__
  442. {
  443. #ifdef __AFX_H__
  444. DECLARE_DYNAMIC( CClusPropList );
  445. #endif // __AFX_H__
  446. public:
  447. //
  448. // Construction.
  449. //
  450. // Default constructor
  451. CClusPropList( IN BOOL bAlwaysAddProp = FALSE )
  452. : m_bAlwaysAddProp( bAlwaysAddProp )
  453. , m_cbBufferSize( 0 )
  454. , m_cbDataSize( 0 )
  455. , m_cbDataLeft( 0 )
  456. , m_nPropsRemaining( 0 )
  457. {
  458. m_cbhPropList.pList = NULL;
  459. m_cbhCurrentProp.pb = NULL;
  460. m_cbhCurrentPropName.pb = NULL;
  461. } //*** CClusPropList()
  462. // Destructor
  463. ~CClusPropList( void )
  464. {
  465. DeletePropList();
  466. } //*** ~CClusPropList()
  467. // Copy list into this list (like assignment operator)
  468. DWORD ScCopy( IN const PCLUSPROP_LIST pcplPropList, IN DWORD cbListSize );
  469. // Delete the property list buffer and cleanup support variables
  470. void DeletePropList( void )
  471. {
  472. delete [] m_cbhPropList.pb;
  473. m_cbhPropList.pb = NULL;
  474. m_cbhCurrentProp.pb = NULL;
  475. m_cbhCurrentPropName.pb = NULL;
  476. m_cbBufferSize = 0;
  477. m_cbDataSize = 0;
  478. m_cbDataLeft = 0;
  479. } //*** DeletePropList()
  480. protected:
  481. //
  482. // Attributes.
  483. //
  484. BOOL m_bAlwaysAddProp; // Indicate if properties should be added even if not different.
  485. CLUSPROP_BUFFER_HELPER m_cbhPropList; // Pointer to the beginning of the list.
  486. CLUSPROP_BUFFER_HELPER m_cbhCurrentProp; // Pointer to the current property.
  487. DWORD m_cbBufferSize; // Allocated size of the buffer.
  488. DWORD m_cbDataSize; // Amount of data in the buffer.
  489. DWORD m_cbDataLeft; // Amount of data left in buffer after current value.
  490. private:
  491. CLUSPROP_BUFFER_HELPER m_cbhCurrentPropName; // Pointer to the current name for parsing
  492. DWORD m_nPropsRemaining; // Used by BMoveToNextProperty() to track end of list.
  493. CClusPropValueList m_pvlValues; // Helper class for value list of current property.
  494. public:
  495. //
  496. // Accessor methods.
  497. //
  498. // Access the values of the current property
  499. const CClusPropValueList & RPvlPropertyValue( void )
  500. {
  501. return m_pvlValues;
  502. } //*** RPvlPropertyValue()
  503. // Access the property list
  504. operator PCLUSPROP_LIST( void ) const
  505. {
  506. return m_cbhPropList.pList;
  507. } //*** operator PCLUSPROP_LIST()
  508. // Access allocated size of the buffer
  509. DWORD CbBufferSize( void ) const
  510. {
  511. return m_cbBufferSize;
  512. } //*** CbBufferSize()
  513. // Access the name of the current property
  514. LPCWSTR PszCurrentPropertyName( void ) const
  515. {
  516. return m_cbhCurrentPropName.pName->sz;
  517. } //*** PszCurrentPropertyName()
  518. // Access the current property name as a buffer helper
  519. const CLUSPROP_BUFFER_HELPER CbhCurrentPropertyName( void )
  520. {
  521. return m_cbhCurrentPropName;
  522. } //*** CbhCurrentPropertyName()
  523. // Access value list of the current property as a buffer helper
  524. const CLUSPROP_BUFFER_HELPER CbhCurrentValueList( void )
  525. {
  526. return m_pvlValues.CbhValueList();
  527. } //*** CbhCurrentValueList()
  528. // Access current value of the current property as a buffer helper
  529. const CLUSPROP_BUFFER_HELPER CbhCurrentValue( void )
  530. {
  531. return m_pvlValues.CbhCurrentValue();
  532. } //*** CbhCurrentValue()
  533. // Access the format of the current value of the current property
  534. CLUSTER_PROPERTY_FORMAT CpfCurrentValueFormat( void ) const
  535. {
  536. return m_pvlValues.CpfCurrentValueFormat();
  537. } //*** CpfCurrentValueFormat()
  538. // Access the format of the current format list syntax entry
  539. CLUSTER_PROPERTY_FORMAT CpfCurrentFormatListSyntax( void ) const
  540. {
  541. return m_pvlValues.CpfCurrentFormatListSyntax();
  542. } //*** CpfCurrentFormatListSyntax()
  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. #ifdef CLUSAPI_VERSION
  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 size_t cbsz = 0
  740. );
  741. void CopyExpandSzProp(
  742. IN PCLUSPROP_SZ pprop,
  743. IN CLUSTER_PROPERTY_TYPE proptype,
  744. IN LPCWSTR psz,
  745. IN size_t cbsz = 0
  746. );
  747. void CopyMultiSzProp(
  748. IN PCLUSPROP_MULTI_SZ pprop,
  749. IN CLUSTER_PROPERTY_TYPE proptype,
  750. IN LPCWSTR psz,
  751. IN size_t 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 size_t 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. /////////////////////////////////////////////////////////////////////////////
  783. #pragma warning( default : 4201 )
  784. /////////////////////////////////////////////////////////////////////////////
  785. #endif // _PROPLIST_H_