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.

134 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. enum.cxx
  5. Abstract:
  6. General metadata utility functions.
  7. Author:
  8. Keith Moore (keithmo) 05-Feb-1997
  9. Revision History:
  10. --*/
  11. #include "precomp.hxx"
  12. #pragma hdrstop
  13. //
  14. // Private constants.
  15. //
  16. #define INITIAL_BUFFER_SIZE 64
  17. //
  18. // Private types.
  19. //
  20. //
  21. // Private globals.
  22. //
  23. //
  24. // Private prototypes.
  25. //
  26. //
  27. // Public functions.
  28. //
  29. HRESULT
  30. MdGetAllMetaData(
  31. IN IMSAdminBase * AdmCom,
  32. IN METADATA_HANDLE Handle,
  33. IN LPWSTR Path,
  34. IN DWORD Attributes,
  35. OUT METADATA_GETALL_RECORD ** Data,
  36. OUT DWORD * NumEntries
  37. )
  38. {
  39. HRESULT result;
  40. DWORD dataSet;
  41. DWORD bytesRequired;
  42. DWORD bufferLength;
  43. LPVOID buffer;
  44. bufferLength = INITIAL_BUFFER_SIZE;
  45. buffer = NULL;
  46. while( TRUE ) {
  47. if( buffer != NULL ) {
  48. MdpFreeMem( buffer );
  49. }
  50. buffer = MdpAllocMem( bufferLength );
  51. if( buffer == NULL ) {
  52. result = HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  53. break;
  54. }
  55. result = AdmCom->GetAllData(
  56. Handle,
  57. Path,
  58. Attributes,
  59. ALL_METADATA,
  60. ALL_METADATA,
  61. NumEntries,
  62. &dataSet,
  63. bufferLength,
  64. (BYTE *)buffer,
  65. &bytesRequired
  66. );
  67. if( SUCCEEDED(result) ) {
  68. break;
  69. }
  70. if( result != RETURNCODETOHRESULT( ERROR_INSUFFICIENT_BUFFER ) ) {
  71. break;
  72. }
  73. bufferLength = bytesRequired;
  74. }
  75. if( SUCCEEDED(result) ) {
  76. *Data = (METADATA_GETALL_RECORD *)buffer;
  77. } else if( buffer != NULL ) {
  78. MdpFreeMem( buffer );
  79. }
  80. return result;
  81. } // MdGetAllMetaData
  82. HRESULT
  83. MdFreeMetaDataBuffer(
  84. IN VOID * Data
  85. )
  86. {
  87. MdpFreeMem( Data );
  88. return NO_ERROR;
  89. } // MdFreeMetaDataBuffer
  90. //
  91. // Private functions.
  92. //