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.

141 lines
3.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: adscopy.cxx
  7. //
  8. // Contents: ADS Object Copy Routines
  9. //
  10. // Functions:
  11. //
  12. // History: 25-Apr-96 KrishnaG Created.
  13. //
  14. //
  15. // Issues: Check null ptrs for AllocADsMem and AllocADsStr
  16. //
  17. // Object Types 6, 13, 16, and 21 are flaky - pay extra attn.
  18. //
  19. //
  20. //----------------------------------------------------------------------------
  21. #include "nds.hxx"
  22. //
  23. // ADsType objects copy code
  24. //
  25. HRESULT
  26. ADsTypeCopy(
  27. PADSVALUE lpADsSrcObject,
  28. PADSVALUE lpADsDestObject
  29. )
  30. {
  31. HRESULT hr = S_OK;
  32. lpADsDestObject->dwType = lpADsSrcObject->dwType;
  33. switch (lpADsSrcObject->dwType) {
  34. case ADSTYPE_DN_STRING:
  35. lpADsDestObjec->DnString = lpADsSrcObject->DNString;
  36. break;
  37. case ADSTYPE_CASE_EXACT_STRING:
  38. lpADsDestObjec->CaseExactString = lpADsSrcObject->CaseExactString;
  39. break;
  40. case ADSTYPE_CASE_IGNORE_STRING:
  41. lpADsDestObjec->CaseIgnoreString = lpADsSrcObject->CaseIgnoreString;
  42. break;
  43. case ADSTYPE_PRINTABLE_STRING:
  44. lpADsDestObjec->PrintableString = lpADsSrcObject->PrintableString;
  45. break;
  46. case ADSTYPE_NUMERIC_STRING:
  47. lpADsDestObjec->NumericString = lpADsSrcObject->NumericString;
  48. break;
  49. case ADSTYPE_BOOLEAN:
  50. lpADsDestObjec->Boolean = lpADsSrcObject->Boolean;
  51. break;
  52. case ADSTYPE_INTEGER:
  53. lpADsDestObjec->Integer = lpADsSrcObject->Integer;
  54. break;
  55. case ADSTYPE_OCTET_STRING:
  56. lpADsDestObjec->OctetString.dwLength = lpADsSrcObject->OctetString.dwLength;
  57. lpADsDestObjec->OctetString.lpValue = AllocADsMem(lpADsSrcObject->OctetString.dwLength);
  58. if (!lpADsDestObjec->OctetString.lpValue) {
  59. RRETURN(E_OUTOFMEMORY);
  60. }
  61. break;
  62. case ADSTYPE_UTC_TIME:
  63. lpADsDestObjec->UTCTime = lpADsSrcObject->UTCTime;
  64. break;
  65. case ADSTYPE_LARGE_INTEGER:
  66. lpADsDestObjec->LargeInteger = lpADsSrcObject->LargeInteger;
  67. break;
  68. case ADSTYPE_PROV_SPECIFIC:
  69. lpADsDestObjec->ProviderSpecific.dwLength = lpADsSrcObject->ProviderSpecific.dwLength;
  70. lpADsDestObjec->ProviderSpecific.lpValue = AllocADsMem(lpADsSrcObject->ProviderSpecific.dwLength);
  71. if (!lpADsDestObjec->ProviderSpecific.lpValue) {
  72. RRETURN(E_OUTOFMEMORY);
  73. }
  74. lpADsDestObjec->DnString = lpADsSrcObject->DNString;
  75. break;
  76. case ADSTYPE_OBJECT_CLASS:
  77. lpADsDestObjec->ClassName = lpADsSrcObject->ClassName;
  78. break;
  79. default:
  80. hr = E_FAIL;
  81. break;
  82. }
  83. RRETURN(hr);
  84. }
  85. HRESULT
  86. ADsTypeCopyConstruct(
  87. LPADSVALUE pADsSrcObjects,
  88. DWORD dwNumObjects,
  89. LPADSVALUE * ppADsDestObjects
  90. )
  91. {
  92. DWORD i = 0;
  93. LPADSVALUE pADsDestObjects = NULL;
  94. HRESULT hr = S_OK;
  95. pADsDestObjects = (LPADSVALUE)AllocADsMem(
  96. dwNumObjects * sizeof(ADSVALUE)
  97. );
  98. if (!pADsDestObjects) {
  99. RRETURN(E_FAIL);
  100. }
  101. for (i = 0; i < dwNumObjects; i++ ) {
  102. hr = ADsTypeCopy(pADsSrcObjects + i, pADsDestObjects + i);
  103. }
  104. *ppADsDestObjects = pADsDestObjects;
  105. RRETURN(S_OK);
  106. }