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.

150 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. metasub.cxx
  5. Abstract:
  6. IIS MetaBase handle routines
  7. Author:
  8. Michael W. Thomas 04-Oct-96
  9. Revision History:
  10. Notes:
  11. --*/
  12. #include "precomp.hxx"
  13. DWORD
  14. CMDHandle::SetChangeData(CMDBaseObject *pboChanged,
  15. DWORD dwChangeType,
  16. DWORD dwDataID,
  17. LPWSTR pszOldName)
  18. {
  19. PCHANGE_ENTRY pceIndex;
  20. DWORD i;
  21. DWORD dwReturn = ERROR_SUCCESS;
  22. for (pceIndex = m_pceChangeList; pceIndex != NULL; pceIndex = pceIndex->NextPtr) {
  23. if (pceIndex->pboChanged == pboChanged) {
  24. break;
  25. }
  26. }
  27. if (pceIndex == NULL) {
  28. pceIndex = new(CHANGE_ENTRY);
  29. if (pceIndex == NULL) {
  30. dwReturn = ERROR_NOT_ENOUGH_MEMORY;
  31. }
  32. else {
  33. pceIndex->dwNumDataIDs = 0;
  34. pceIndex->pbufDataIDs = NULL;
  35. pceIndex->dwChangeType = 0;
  36. pceIndex->pboChanged = pboChanged;
  37. pceIndex->NextPtr = m_pceChangeList;
  38. pceIndex->pStrOrigName = NULL;
  39. m_pceChangeList = pceIndex;
  40. }
  41. }
  42. if (dwReturn == ERROR_SUCCESS) {
  43. MD_ASSERT(pceIndex != NULL);
  44. pceIndex->dwChangeType |= dwChangeType;
  45. if ((dwChangeType == MD_CHANGE_TYPE_SET_DATA) ||
  46. (dwChangeType == MD_CHANGE_TYPE_DELETE_DATA) ||
  47. (dwChangeType == MD_CHANGE_TYPE_RENAME_OBJECT && pszOldName != NULL )) {
  48. if (pceIndex->pbufDataIDs == NULL) {
  49. pceIndex->pbufDataIDs = new BUFFER();
  50. if (pceIndex->pbufDataIDs == NULL) {
  51. dwReturn = ERROR_NOT_ENOUGH_MEMORY;
  52. }
  53. }
  54. if (dwReturn == ERROR_SUCCESS && pceIndex->pStrOrigName == NULL && pszOldName !=NULL) {
  55. pceIndex->pStrOrigName = new STRAU();
  56. if (pceIndex->pStrOrigName == NULL) {
  57. dwReturn = ERROR_NOT_ENOUGH_MEMORY;
  58. }
  59. else
  60. {
  61. // sucess
  62. // we are taking the old name of metabase key only once.
  63. // so if subsequent renames will happen we will return the oldest one
  64. if ( !pceIndex->pStrOrigName->Copy (pszOldName) )
  65. {
  66. dwReturn = ERROR_NOT_ENOUGH_MEMORY;
  67. }
  68. }
  69. }
  70. if (dwReturn == ERROR_SUCCESS) {
  71. for (i = 0; i < pceIndex->dwNumDataIDs; i++) {
  72. if (((DWORD *)(pceIndex->pbufDataIDs->QueryPtr()))[i] == dwDataID) {
  73. break;
  74. }
  75. }
  76. if (i == pceIndex->dwNumDataIDs) {
  77. if (!pceIndex->pbufDataIDs->Resize((pceIndex->dwNumDataIDs + 1) * sizeof(DWORD))) {
  78. dwReturn = ERROR_NOT_ENOUGH_MEMORY;
  79. }
  80. else {
  81. ((DWORD *)(pceIndex->pbufDataIDs->QueryPtr()))[pceIndex->dwNumDataIDs] = dwDataID;
  82. pceIndex->dwNumDataIDs++;
  83. }
  84. }
  85. }
  86. }
  87. }
  88. return dwReturn;
  89. }
  90. CMDHandle::~CMDHandle()
  91. {
  92. RemoveNotifications();
  93. }
  94. PCHANGE_ENTRY
  95. CMDHandle::EnumChangeEntries(DWORD dwIndex)
  96. {
  97. PCHANGE_ENTRY pceIndex;
  98. DWORD i;
  99. for (i = 0, pceIndex = m_pceChangeList;
  100. pceIndex != NULL && i < dwIndex;
  101. i++, pceIndex = pceIndex->NextPtr) {
  102. }
  103. return pceIndex;
  104. }
  105. DWORD
  106. CMDHandle::GetNumChangeEntries()
  107. {
  108. DWORD dwCount = 0;
  109. PCHANGE_ENTRY pceIndex;
  110. for (pceIndex = m_pceChangeList;
  111. pceIndex !=NULL;
  112. pceIndex = pceIndex->NextPtr) {
  113. dwCount++;
  114. }
  115. return dwCount;
  116. }
  117. VOID
  118. CMDHandle::RemoveNotifications()
  119. {
  120. PCHANGE_ENTRY pceIndex, pceNext;
  121. for (pceIndex = m_pceChangeList; pceIndex != NULL; pceIndex = pceNext) {
  122. pceNext = pceIndex->NextPtr;
  123. delete(pceIndex->pbufDataIDs);
  124. delete(pceIndex->pStrOrigName);
  125. if ((pceIndex->dwChangeType & MD_CHANGE_TYPE_DELETE_OBJECT) != 0) {
  126. delete(pceIndex->pboChanged);
  127. }
  128. delete(pceIndex);
  129. }
  130. m_pceChangeList = NULL;
  131. }
  132.