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.

195 lines
4.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: nw2ods.cxx
  7. //
  8. // Contents: NDS Object to Variant Copy Routines
  9. //
  10. // Functions:
  11. //
  12. // History: 25-Apr-96 KrishnaG Created.
  13. //
  14. //
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "nwcompat.hxx"
  18. #pragma hdrstop
  19. HRESULT
  20. NTTypeToAdsTypeCopyString(
  21. PNTOBJECT lpNtSrcObject,
  22. PADSVALUE lpAdsDestValue
  23. )
  24. {
  25. HRESULT hr = S_OK;
  26. lpAdsDestValue->dwType = ADSTYPE_CASE_IGNORE_STRING;
  27. lpAdsDestValue->DNString =
  28. AllocADsStr(
  29. lpNtSrcObject->NTValue.pszValue
  30. );
  31. if ((!lpAdsDestValue->DNString) &&
  32. (lpNtSrcObject->NTValue.pszValue)) {
  33. RRETURN(E_OUTOFMEMORY);
  34. }
  35. RRETURN(hr);
  36. }
  37. HRESULT
  38. NTTypeToAdsTypeCopyBoolean(
  39. PNTOBJECT lpNtSrcObject,
  40. PADSVALUE lpAdsDestValue
  41. )
  42. {
  43. HRESULT hr = S_OK;
  44. lpAdsDestValue->dwType = ADSTYPE_BOOLEAN;
  45. lpAdsDestValue->Boolean =
  46. lpNtSrcObject->NTValue.fValue;
  47. RRETURN(hr);
  48. }
  49. HRESULT
  50. NTTypeToAdsTypeCopyInteger(
  51. PNTOBJECT lpNtSrcObject,
  52. PADSVALUE lpAdsDestValue
  53. )
  54. {
  55. HRESULT hr = S_OK;
  56. lpAdsDestValue->dwType = ADSTYPE_INTEGER;
  57. lpAdsDestValue->Integer =
  58. lpNtSrcObject->NTValue.dwValue;
  59. RRETURN(hr);
  60. }
  61. HRESULT
  62. NTTypeToAdsTypeCopy(
  63. PNTOBJECT lpNtSrcObject,
  64. PADSVALUE lpAdsDestValue
  65. )
  66. {
  67. HRESULT hr = S_OK;
  68. switch (lpNtSrcObject->NTType) {
  69. case NT_SYNTAX_ID_BOOL:
  70. hr = NTTypeToAdsTypeCopyBoolean(
  71. lpNtSrcObject,
  72. lpAdsDestValue
  73. );
  74. break;
  75. case NT_SYNTAX_ID_DWORD:
  76. hr = NTTypeToAdsTypeCopyInteger(
  77. lpNtSrcObject,
  78. lpAdsDestValue
  79. );
  80. break;
  81. case NT_SYNTAX_ID_LPTSTR:
  82. hr = NTTypeToAdsTypeCopyString(
  83. lpNtSrcObject,
  84. lpAdsDestValue
  85. );
  86. break;
  87. /*
  88. case NT_SYNTAX_ID_SYSTEMTIME:
  89. case NT_SYNTAX_ID_DATE:
  90. case NT_SYNTAX_ID_NW312TIME:
  91. hr = NTTypeToAdsTypeCopyNDSSynId4(
  92. lpNtSrcObject,
  93. lpAdsDestValue
  94. );
  95. break;
  96. case NT_SYNTAX_ID_NulledString:
  97. hr = NTTypeToAdsTypeCopyNDSSynId5(
  98. lpNtSrcObject,
  99. lpAdsDestValue
  100. );
  101. break;
  102. case NT_SYNTAX_ID_DelimitedString:
  103. hr = NTTypeToAdsTypeCopyNDSSynId6(
  104. lpNtSrcObject,
  105. lpAdsDestValue
  106. );
  107. break;
  108. */
  109. default:
  110. hr = E_FAIL;
  111. break;
  112. }
  113. RRETURN(hr);
  114. }
  115. HRESULT
  116. NTTypeToAdsTypeCopyConstruct(
  117. LPNTOBJECT pNtSrcObjects,
  118. DWORD dwNumObjects,
  119. LPADSVALUE * ppAdsDestValues
  120. )
  121. {
  122. DWORD i = 0;
  123. LPADSVALUE pAdsDestValues = NULL;
  124. HRESULT hr = S_OK;
  125. if (!dwNumObjects) {
  126. *ppAdsDestValues =0;
  127. RRETURN(S_OK);
  128. }
  129. pAdsDestValues = (LPADSVALUE)AllocADsMem(
  130. dwNumObjects * sizeof(ADSVALUE)
  131. );
  132. if (!pAdsDestValues) {
  133. RRETURN(E_OUTOFMEMORY);
  134. }
  135. for (i = 0; i < dwNumObjects; i++ ) {
  136. hr = NTTypeToAdsTypeCopy(
  137. pNtSrcObjects + i,
  138. pAdsDestValues + i
  139. );
  140. BAIL_ON_FAILURE(hr);
  141. }
  142. *ppAdsDestValues = pAdsDestValues;
  143. RRETURN(S_OK);
  144. error:
  145. if (pAdsDestValues) {
  146. AdsFreeAdsValues(
  147. pAdsDestValues,
  148. dwNumObjects
  149. );
  150. FreeADsMem(pAdsDestValues);
  151. }
  152. *ppAdsDestValues = NULL;
  153. RRETURN(hr);
  154. }