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.

154 lines
4.0 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1998 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusObj.cpp
  7. //
  8. // Description:
  9. // Implementation of the CClusterObject classes.
  10. //
  11. // Author:
  12. // David Potter (davidp) September 15, 1998
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "ClusObj.h"
  20. #include "AdmCommonRes.h"
  21. /////////////////////////////////////////////////////////////////////////////
  22. // class CClusResInfo
  23. /////////////////////////////////////////////////////////////////////////////
  24. /////////////////////////////////////////////////////////////////////////////
  25. //++
  26. //
  27. // CClusResInfo::BRequiredDependenciesPresent
  28. //
  29. // Routine Description:
  30. // Determine if the resource contains each required resource for this
  31. // type of resource.
  32. //
  33. // Arguments:
  34. // plpri [IN] List of resources. Defaults to this resource's
  35. // dependency list.
  36. // rstrMissing [OUT] String in which to return a missing resource
  37. // class name or type name.
  38. // rbMissingTypeName
  39. // [OUT] TRUE = missing resource type name
  40. // FALSE = missing resource class
  41. //
  42. // Return Value:
  43. // None.
  44. //
  45. // Exceptions Thrown:
  46. // Any exceptions thrown by CString::LoadString() or CString::operator=().
  47. //
  48. //--
  49. /////////////////////////////////////////////////////////////////////////////
  50. BOOL CClusResInfo::BRequiredDependenciesPresent(
  51. IN CClusResPtrList const * plpri,
  52. OUT CString & rstrMissing,
  53. OUT BOOL & rbMissingTypeName
  54. )
  55. {
  56. ATLASSERT( Prti() != NULL );
  57. BOOL bFound = TRUE;
  58. CLUSPROP_BUFFER_HELPER buf;
  59. const CClusResInfo * pri;
  60. // Loop to avoid goto's.
  61. do
  62. {
  63. //
  64. // We're done if there are no required dependencies.
  65. //
  66. if ( Prti()->Pcrd() == NULL )
  67. {
  68. break;
  69. } // if: no required dependencies
  70. //
  71. // Default the list of resources if none specified.
  72. //
  73. if ( plpri == NULL )
  74. {
  75. plpri = PlpriDependencies();
  76. } // if: no list of dependencies specified
  77. //
  78. // Get the list of required dependencies.
  79. //
  80. buf.pRequiredDependencyValue = Prti()->Pcrd();
  81. //
  82. // Loop through each required dependency and make sure
  83. // there is a dependency on a resource of that type.
  84. //
  85. for ( ; buf.pSyntax->dw != CLUSPROP_SYNTAX_ENDMARK
  86. ; buf.pb += sizeof( *buf.pValue ) + ALIGN_CLUSPROP( buf.pValue->cbLength )
  87. )
  88. {
  89. bFound = FALSE;
  90. CClusResPtrList::iterator itCurrent = plpri->begin();
  91. CClusResPtrList::iterator itLast = plpri->end();
  92. for ( ; itCurrent != itLast ; itCurrent++ )
  93. {
  94. pri = *itCurrent;
  95. //
  96. // If this is the right type, we've satisfied the
  97. // requirement so exit the loop.
  98. //
  99. if ( buf.pSyntax->dw == CLUSPROP_SYNTAX_RESCLASS )
  100. {
  101. if ( buf.pResourceClassValue->rc == pri->ResClass() )
  102. {
  103. bFound = TRUE;
  104. } // if: match found
  105. } // if: resource class
  106. else if ( buf.pSyntax->dw == CLUSPROP_SYNTAX_NAME )
  107. {
  108. if ( pri->Prti()->RstrName().CompareNoCase( buf.pStringValue->sz ) == 0 )
  109. {
  110. bFound = TRUE;
  111. } // if: match found
  112. } // else if: resource name
  113. if ( bFound )
  114. {
  115. break;
  116. } // if: found a match
  117. } // while: more items in the list
  118. //
  119. // If a match was not found, changes cannot be applied.
  120. //
  121. if ( ! bFound )
  122. {
  123. if ( buf.pSyntax->dw == CLUSPROP_SYNTAX_RESCLASS )
  124. {
  125. if ( ! rstrMissing.LoadString( ADMC_IDS_RESCLASS_UNKNOWN + buf.pResourceClassValue->rc ) )
  126. {
  127. rstrMissing.LoadString( ADMC_IDS_RESCLASS_UNKNOWN );
  128. } // if: error loading specific class name
  129. rbMissingTypeName = FALSE;
  130. } // if: resource class not found
  131. else if ( buf.pSyntax->dw == CLUSPROP_SYNTAX_NAME )
  132. {
  133. rstrMissing = buf.pStringValue->sz;
  134. rbMissingTypeName = TRUE;
  135. } // else if: resource type name not found
  136. break;
  137. } // if: not found
  138. } // while: more dependencies required
  139. } while ( 0 );
  140. return bFound;
  141. } //*** CClusResInfo::BRequiredDependenciesPresent()