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.

213 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module Copy.cxx | Implementation of VSS_OBJECT_PROP_Copy and VSS_OBJECT_PROP_Ptr classes
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 09/01/1999
  9. Remarks:
  10. It cannot be put into a library because of ATL code.
  11. Revision History:
  12. Name Date Comments
  13. aoltean 09/01/1999 Created
  14. aoltean 09/09/1999 dss -> vss
  15. aoltean 09/13/1999 Moved to inc. Renamed to copy.inl
  16. aoltean 09/20/1999 Adding methods for creating the snapshot, snapshot set,
  17. provider and volume property structures.
  18. Also VSS_OBJECT_PROP_Manager renamed to VSS_OBJECT_PROP_Manager.
  19. aoltean 09/21/1999 Renaming back VSS_OBJECT_PROP_Manager to VSS_OBJECT_PROP_Copy.
  20. Moving the CreateXXX into VSS_OBJECT_PROP_Ptr::InstantiateAsXXX
  21. aoltean 09/22/1999 Fixing VSSDBG_GEN.
  22. aoltean 09/24/1999 Moving into modules/prop
  23. aoltean 12/16/1999 Adding specialized copyXXX methods
  24. --*/
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Needed includes
  27. #include "stdafx.hxx"
  28. #include "vs_inc.hxx"
  29. // Generated file from Coord.IDL
  30. #include "vs_idl.hxx"
  31. #include "copy.hxx"
  32. ////////////////////////////////////////////////////////////////////////
  33. // Standard foo for file name aliasing. This code block must be after
  34. // all includes of VSS header files.
  35. //
  36. #ifdef VSS_FILE_ALIAS
  37. #undef VSS_FILE_ALIAS
  38. #endif
  39. #define VSS_FILE_ALIAS "PRPCOPYC"
  40. //
  41. ////////////////////////////////////////////////////////////////////////
  42. /////////////////////////////////////////////////////////////////////////////
  43. // VSS_OBJECT_PROP_Copy class
  44. HRESULT VSS_OBJECT_PROP_Copy::copySnapshot(
  45. IN VSS_SNAPSHOT_PROP* pObj1,
  46. IN VSS_SNAPSHOT_PROP* pObj2
  47. )
  48. {
  49. CVssFunctionTracer ft( VSSDBG_GEN, L"VSS_OBJECT_PROP_Copy::copySnapshot" );
  50. try
  51. {
  52. // Testing arguments
  53. BS_ASSERT(pObj1 != NULL);
  54. BS_ASSERT(pObj2 != NULL);
  55. // Copy the members
  56. pObj1->m_SnapshotId = pObj2->m_SnapshotId;
  57. pObj1->m_SnapshotSetId = pObj2->m_SnapshotSetId;
  58. pObj1->m_lSnapshotsCount = pObj2->m_lSnapshotsCount;
  59. ::VssSafeDuplicateStr( ft, pObj1->m_pwszSnapshotDeviceObject, pObj2->m_pwszSnapshotDeviceObject );
  60. ::VssSafeDuplicateStr( ft, pObj1->m_pwszOriginalVolumeName, pObj2->m_pwszOriginalVolumeName );
  61. ::VssSafeDuplicateStr( ft, pObj1->m_pwszOriginatingMachine, pObj2->m_pwszOriginatingMachine );
  62. ::VssSafeDuplicateStr( ft, pObj1->m_pwszServiceMachine, pObj2->m_pwszServiceMachine );
  63. ::VssSafeDuplicateStr( ft, pObj1->m_pwszExposedName, pObj2->m_pwszExposedName );
  64. ::VssSafeDuplicateStr( ft, pObj1->m_pwszExposedPath, pObj2->m_pwszExposedPath );
  65. pObj1->m_ProviderId = pObj2->m_ProviderId;
  66. pObj1->m_lSnapshotAttributes = pObj2->m_lSnapshotAttributes;
  67. pObj1->m_tsCreationTimestamp = pObj2->m_tsCreationTimestamp;
  68. pObj1->m_eStatus = pObj2->m_eStatus;
  69. }
  70. VSS_STANDARD_CATCH(ft)
  71. return ft.hr;
  72. }
  73. HRESULT VSS_OBJECT_PROP_Copy::copyProvider(
  74. IN VSS_PROVIDER_PROP* pObj1,
  75. IN VSS_PROVIDER_PROP* pObj2
  76. )
  77. {
  78. CVssFunctionTracer ft( VSSDBG_GEN, L"VSS_OBJECT_PROP_Copy::copyProvider" );
  79. try
  80. {
  81. // Testing arguments
  82. BS_ASSERT(pObj1 != NULL);
  83. BS_ASSERT(pObj2 != NULL);
  84. // Copy the members
  85. pObj1->m_ProviderId = pObj2->m_ProviderId;
  86. ::VssSafeDuplicateStr( ft, pObj1->m_pwszProviderName, pObj2->m_pwszProviderName );
  87. pObj1->m_eProviderType = pObj2->m_eProviderType;
  88. ::VssSafeDuplicateStr( ft, pObj1->m_pwszProviderVersion, pObj2->m_pwszProviderVersion );
  89. pObj1->m_ProviderVersionId = pObj2->m_ProviderVersionId;
  90. pObj1->m_ClassId = pObj2->m_ClassId;
  91. }
  92. VSS_STANDARD_CATCH(ft)
  93. return ft.hr;
  94. }
  95. HRESULT VSS_OBJECT_PROP_Copy::copy(
  96. IN VSS_OBJECT_PROP* pObj1,
  97. IN VSS_OBJECT_PROP* pObj2
  98. )
  99. {
  100. HRESULT hr;
  101. // Testing arguments
  102. if ((pObj1 == NULL) || (pObj2 == NULL))
  103. return E_INVALIDARG;
  104. // Zeroing the contents of the destination structure
  105. ::VssZeroOut(pObj1);
  106. // Copy the type
  107. pObj1->Type = pObj2->Type;
  108. // Effective copy
  109. switch(pObj2->Type)
  110. {
  111. case VSS_OBJECT_SNAPSHOT:
  112. hr = copySnapshot( &(pObj1->Obj.Snap), &(pObj2->Obj.Snap) );
  113. break;
  114. case VSS_OBJECT_PROVIDER:
  115. hr = copyProvider( &(pObj1->Obj.Prov), &(pObj2->Obj.Prov) );
  116. break;
  117. default:
  118. BS_ASSERT(false);
  119. hr = E_UNEXPECTED;
  120. break;
  121. }
  122. return hr;
  123. }
  124. void VSS_OBJECT_PROP_Copy::init(
  125. IN VSS_OBJECT_PROP* pObjectProp
  126. )
  127. {
  128. CVssFunctionTracer ft( VSSDBG_GEN, L"VSS_OBJECT_PROP_Copy::init" );
  129. try
  130. {
  131. // Zeroing the contents of the structure
  132. ::VssZeroOut(pObjectProp);
  133. }
  134. VSS_STANDARD_CATCH(ft)
  135. }
  136. void VSS_OBJECT_PROP_Copy::destroy(
  137. IN VSS_OBJECT_PROP* pObjectProp
  138. )
  139. {
  140. CVssFunctionTracer ft( VSSDBG_GEN, L"VSS_OBJECT_PROP_Copy::destroy" );
  141. try
  142. {
  143. if (pObjectProp)
  144. {
  145. switch(pObjectProp->Type)
  146. {
  147. case VSS_OBJECT_SNAPSHOT:
  148. ::VssFreeString(pObjectProp->Obj.Snap.m_pwszOriginalVolumeName);
  149. ::VssFreeString(pObjectProp->Obj.Snap.m_pwszSnapshotDeviceObject);
  150. ::VssFreeString(pObjectProp->Obj.Snap.m_pwszOriginatingMachine);
  151. ::VssFreeString(pObjectProp->Obj.Snap.m_pwszServiceMachine);
  152. ::VssFreeString(pObjectProp->Obj.Snap.m_pwszExposedName);
  153. ::VssFreeString(pObjectProp->Obj.Snap.m_pwszExposedPath);
  154. break;
  155. case VSS_OBJECT_PROVIDER:
  156. ::VssFreeString(pObjectProp->Obj.Prov.m_pwszProviderName);
  157. ::VssFreeString(pObjectProp->Obj.Prov.m_pwszProviderVersion);
  158. break;
  159. default:
  160. break;
  161. }
  162. pObjectProp->Type = VSS_OBJECT_UNKNOWN;
  163. }
  164. }
  165. VSS_STANDARD_CATCH(ft)
  166. }