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.

1052 lines
25 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ndscopy.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. //----------------------------------------------------------------------------
  18. #include "nds.hxx"
  19. HRESULT
  20. NdsTypeToAdsTypeCopyNDSSynId1(
  21. PNDSOBJECT lpNdsSrcObject,
  22. PADSVALUE lpAdsDestValue
  23. )
  24. {
  25. HRESULT hr = S_OK;
  26. lpAdsDestValue->dwType = ADSTYPE_DN_STRING;
  27. lpAdsDestValue->DNString =
  28. AllocADsStr(
  29. lpNdsSrcObject->NdsValue.value_1.DNString
  30. );
  31. if (!lpAdsDestValue->DNString) {
  32. hr = E_OUTOFMEMORY;
  33. BAIL_ON_FAILURE(hr);
  34. }
  35. error:
  36. RRETURN(hr);
  37. }
  38. HRESULT
  39. NdsTypeToAdsTypeCopyNDSSynId2(
  40. PNDSOBJECT lpNdsSrcObject,
  41. PADSVALUE lpAdsDestValue
  42. )
  43. {
  44. HRESULT hr = S_OK;
  45. lpAdsDestValue->dwType = ADSTYPE_CASE_EXACT_STRING;
  46. lpAdsDestValue->DNString =
  47. AllocADsStr(
  48. lpNdsSrcObject->NdsValue.value_1.DNString
  49. );
  50. if (!lpAdsDestValue->DNString) {
  51. hr = E_OUTOFMEMORY;
  52. BAIL_ON_FAILURE(hr);
  53. }
  54. error:
  55. RRETURN(hr);
  56. }
  57. HRESULT
  58. NdsTypeToAdsTypeCopyNDSSynId3(
  59. PNDSOBJECT lpNdsSrcObject,
  60. PADSVALUE lpAdsDestValue
  61. )
  62. {
  63. HRESULT hr = S_OK;
  64. lpAdsDestValue->dwType = ADSTYPE_CASE_IGNORE_STRING;
  65. lpAdsDestValue->DNString =
  66. AllocADsStr(
  67. lpNdsSrcObject->NdsValue.value_1.DNString
  68. );
  69. if (!lpAdsDestValue->DNString) {
  70. hr = E_OUTOFMEMORY;
  71. BAIL_ON_FAILURE(hr);
  72. }
  73. error:
  74. RRETURN(hr);
  75. }
  76. HRESULT
  77. NdsTypeToAdsTypeCopyNDSSynId4(
  78. PNDSOBJECT lpNdsSrcObject,
  79. PADSVALUE lpAdsDestValue
  80. )
  81. {
  82. HRESULT hr = S_OK;
  83. lpAdsDestValue->dwType = ADSTYPE_PRINTABLE_STRING;
  84. lpAdsDestValue->DNString =
  85. AllocADsStr(
  86. lpNdsSrcObject->NdsValue.value_1.DNString
  87. );
  88. if (!lpAdsDestValue->DNString) {
  89. hr = E_OUTOFMEMORY;
  90. BAIL_ON_FAILURE(hr);
  91. }
  92. error:
  93. RRETURN(hr);
  94. }
  95. HRESULT
  96. NdsTypeToAdsTypeCopyNDSSynId5(
  97. PNDSOBJECT lpNdsSrcObject,
  98. PADSVALUE lpAdsDestValue
  99. )
  100. {
  101. HRESULT hr = S_OK;
  102. lpAdsDestValue->dwType = ADSTYPE_NUMERIC_STRING;
  103. lpAdsDestValue->DNString =
  104. AllocADsStr(
  105. lpNdsSrcObject->NdsValue.value_1.DNString
  106. );
  107. if (!lpAdsDestValue->DNString) {
  108. hr = E_OUTOFMEMORY;
  109. BAIL_ON_FAILURE(hr);
  110. }
  111. error:
  112. RRETURN(hr);
  113. }
  114. HRESULT
  115. NdsTypeToAdsTypeCopyNDSSynId6(
  116. PNDSOBJECT lpNdsSrcObject,
  117. PADSVALUE lpAdsDestValue
  118. )
  119. {
  120. HRESULT hr = S_OK;
  121. struct _NDS_CI_LIST *pNdsNext = &lpNdsSrcObject->NdsValue.value_6;
  122. PADS_CASEIGNORE_LIST pAdsOutput = NULL;
  123. PADS_CASEIGNORE_LIST pAdsCurrent = NULL;
  124. lpAdsDestValue->dwType = ADSTYPE_CASEIGNORE_LIST;
  125. lpAdsDestValue->pCaseIgnoreList = (PADS_CASEIGNORE_LIST)AllocADsMem(sizeof(ADS_CASEIGNORE_LIST));
  126. if (!lpAdsDestValue->pCaseIgnoreList) {
  127. hr = E_OUTOFMEMORY;
  128. BAIL_ON_FAILURE(hr);
  129. }
  130. pAdsOutput = lpAdsDestValue->pCaseIgnoreList;
  131. pAdsOutput->String = AllocADsStr(pNdsNext->String);
  132. if (!pAdsOutput->String) {
  133. hr = E_OUTOFMEMORY;
  134. BAIL_ON_FAILURE(hr);
  135. }
  136. pNdsNext = pNdsNext->Next;
  137. while (pNdsNext) {
  138. pAdsCurrent = (PADS_CASEIGNORE_LIST)AllocADsMem(sizeof(ADS_CASEIGNORE_LIST));
  139. if (!pAdsCurrent) {
  140. hr = E_OUTOFMEMORY;
  141. BAIL_ON_FAILURE(hr);
  142. }
  143. pAdsCurrent->String = AllocADsStr(pNdsNext->String);
  144. if (!pAdsCurrent->String) {
  145. hr = E_OUTOFMEMORY;
  146. BAIL_ON_FAILURE(hr);
  147. }
  148. pAdsOutput->Next = pAdsCurrent;
  149. pAdsOutput = pAdsCurrent;
  150. pNdsNext = pNdsNext->Next;
  151. }
  152. pAdsOutput->Next = NULL;
  153. error:
  154. RRETURN(hr);
  155. }
  156. HRESULT
  157. NdsTypeToAdsTypeCopyNDSSynId7(
  158. PNDSOBJECT lpNdsSrcObject,
  159. PADSVALUE lpAdsDestValue
  160. )
  161. {
  162. HRESULT hr = S_OK;
  163. lpAdsDestValue->dwType = ADSTYPE_BOOLEAN;
  164. lpAdsDestValue->Boolean =
  165. lpNdsSrcObject->NdsValue.value_7.Boolean;
  166. RRETURN(hr);
  167. }
  168. HRESULT
  169. NdsTypeToAdsTypeCopyNDSSynId8(
  170. PNDSOBJECT lpNdsSrcObject,
  171. PADSVALUE lpAdsDestValue
  172. )
  173. {
  174. HRESULT hr = S_OK;
  175. lpAdsDestValue->dwType = ADSTYPE_INTEGER;
  176. lpAdsDestValue->Integer =
  177. lpNdsSrcObject->NdsValue.value_8.Integer;
  178. RRETURN(hr);
  179. }
  180. HRESULT
  181. NdsTypeToAdsTypeCopyNDSSynId9(
  182. PNDSOBJECT lpNdsSrcObject,
  183. PADSVALUE lpAdsDestValue
  184. )
  185. {
  186. HRESULT hr = S_OK;
  187. DWORD dwLength = 0;
  188. LPBYTE lpByte = NULL;
  189. lpAdsDestValue->dwType = ADSTYPE_OCTET_STRING;
  190. dwLength = lpNdsSrcObject->NdsValue.value_9.Length;
  191. if (dwLength) {
  192. lpByte = (LPBYTE)AllocADsMem(dwLength);
  193. if (!lpByte) {
  194. hr = E_OUTOFMEMORY;
  195. BAIL_ON_FAILURE(hr);
  196. }
  197. if (lpNdsSrcObject->NdsValue.value_9.OctetString) {
  198. memcpy(lpByte, lpNdsSrcObject->NdsValue.value_9.OctetString, dwLength);
  199. }
  200. lpAdsDestValue->OctetString.dwLength = dwLength;
  201. lpAdsDestValue->OctetString.lpValue = lpByte;
  202. }else {
  203. lpAdsDestValue->OctetString.dwLength = 0;
  204. lpAdsDestValue->OctetString.lpValue = NULL;
  205. }
  206. error:
  207. RRETURN(hr);
  208. }
  209. HRESULT
  210. NdsTypeToAdsTypeCopyNDSSynId10(
  211. PNDSOBJECT lpNdsSrcObject,
  212. PADSVALUE lpAdsDestValue
  213. )
  214. {
  215. HRESULT hr = S_OK;
  216. lpAdsDestValue->dwType = ADSTYPE_CASE_IGNORE_STRING;
  217. lpAdsDestValue->DNString =
  218. AllocADsStr(
  219. lpNdsSrcObject->NdsValue.value_1.DNString
  220. );
  221. if (!lpAdsDestValue->DNString) {
  222. hr = E_OUTOFMEMORY;
  223. BAIL_ON_FAILURE(hr);
  224. }
  225. error:
  226. RRETURN(hr);
  227. }
  228. HRESULT
  229. NdsTypeToAdsTypeCopyNDSSynId11(
  230. PNDSOBJECT lpNdsSrcObject,
  231. PADSVALUE lpAdsDestValue
  232. )
  233. {
  234. HRESULT hr = S_OK;
  235. lpAdsDestValue->dwType = ADSTYPE_FAXNUMBER;
  236. lpAdsDestValue->pFaxNumber = (PADS_FAXNUMBER)AllocADsMem(sizeof(ADS_FAXNUMBER));
  237. if (!lpAdsDestValue->pFaxNumber) {
  238. hr = E_OUTOFMEMORY;
  239. BAIL_ON_FAILURE(hr);
  240. }
  241. lpAdsDestValue->pFaxNumber->TelephoneNumber =
  242. AllocADsStr(lpNdsSrcObject->NdsValue.value_11.TelephoneNumber);
  243. if ((!lpAdsDestValue->pFaxNumber->TelephoneNumber) &&
  244. (lpNdsSrcObject->NdsValue.value_11.TelephoneNumber)){
  245. hr = E_OUTOFMEMORY;
  246. BAIL_ON_FAILURE(hr);
  247. }
  248. hr = CopyOctetString(lpNdsSrcObject->NdsValue.value_11.NumberOfBits,
  249. lpNdsSrcObject->NdsValue.value_11.Parameters,
  250. &lpAdsDestValue->pFaxNumber->NumberOfBits,
  251. &lpAdsDestValue->pFaxNumber->Parameters);
  252. BAIL_ON_FAILURE(hr);
  253. error:
  254. RRETURN(hr);
  255. }
  256. HRESULT
  257. NdsTypeToAdsTypeCopyNDSSynId12(
  258. PNDSOBJECT lpNdsSrcObject,
  259. PADSVALUE lpAdsDestValue
  260. )
  261. {
  262. HRESULT hr = S_OK;
  263. lpAdsDestValue->dwType = ADSTYPE_NETADDRESS;
  264. lpAdsDestValue->pNetAddress = (PADS_NETADDRESS)AllocADsMem(sizeof(ADS_NETADDRESS));
  265. if (!lpAdsDestValue->pNetAddress) {
  266. hr = E_OUTOFMEMORY;
  267. BAIL_ON_FAILURE(hr);
  268. }
  269. lpAdsDestValue->pNetAddress->AddressType =
  270. lpNdsSrcObject->NdsValue.value_12.AddressType;
  271. hr = CopyOctetString(lpNdsSrcObject->NdsValue.value_12.AddressLength,
  272. lpNdsSrcObject->NdsValue.value_12.Address,
  273. &lpAdsDestValue->pNetAddress->AddressLength,
  274. &lpAdsDestValue->pNetAddress->Address);
  275. BAIL_ON_FAILURE(hr);
  276. error:
  277. RRETURN(hr);
  278. }
  279. HRESULT
  280. NdsTypeToAdsTypeCopyNDSSynId13(
  281. PNDSOBJECT lpNdsSrcObject,
  282. PADSVALUE lpAdsDestValue
  283. )
  284. {
  285. HRESULT hr = S_OK;
  286. struct _NDS_OCTET_LIST *pNdsNext = &lpNdsSrcObject->NdsValue.value_13;
  287. PADS_OCTET_LIST pAdsOutput = NULL;
  288. PADS_OCTET_LIST pAdsCurrent = NULL;
  289. lpAdsDestValue->dwType = ADSTYPE_OCTET_LIST;
  290. lpAdsDestValue->pOctetList = (PADS_OCTET_LIST)AllocADsMem(sizeof(ADS_OCTET_LIST));
  291. if (!lpAdsDestValue->pOctetList) {
  292. hr = E_OUTOFMEMORY;
  293. BAIL_ON_FAILURE(hr);
  294. }
  295. pAdsOutput = lpAdsDestValue->pOctetList;
  296. hr = CopyOctetString(pNdsNext->Length,
  297. pNdsNext->Data,
  298. &pAdsOutput->Length,
  299. &pAdsOutput->Data);
  300. BAIL_ON_FAILURE(hr);
  301. pNdsNext = pNdsNext->Next;
  302. while (pNdsNext) {
  303. pAdsCurrent = (PADS_OCTET_LIST)AllocADsMem(sizeof(ADS_OCTET_LIST));
  304. if (!pAdsCurrent) {
  305. hr = E_OUTOFMEMORY;
  306. BAIL_ON_FAILURE(hr);
  307. }
  308. hr = CopyOctetString(pNdsNext->Length,
  309. pNdsNext->Data,
  310. &pAdsOutput->Length,
  311. &pAdsOutput->Data);
  312. BAIL_ON_FAILURE(hr);
  313. pAdsOutput->Next = pAdsCurrent;
  314. pAdsOutput = pAdsCurrent;
  315. pNdsNext = pNdsNext->Next;
  316. }
  317. pAdsOutput->Next = NULL;
  318. error:
  319. RRETURN(hr);
  320. }
  321. HRESULT
  322. NdsTypeToAdsTypeCopyNDSSynId14(
  323. PNDSOBJECT lpNdsSrcObject,
  324. PADSVALUE lpAdsDestValue
  325. )
  326. {
  327. HRESULT hr = S_OK;
  328. lpAdsDestValue->dwType = ADSTYPE_EMAIL;
  329. lpAdsDestValue->Email.Address=
  330. AllocADsStr(
  331. lpNdsSrcObject->NdsValue.value_14.Address
  332. );
  333. if (!lpAdsDestValue->Email.Address) {
  334. hr = E_OUTOFMEMORY;
  335. BAIL_ON_FAILURE(hr);
  336. }
  337. lpAdsDestValue->Email.Type =
  338. lpNdsSrcObject->NdsValue.value_14.Type;
  339. error:
  340. RRETURN(hr);
  341. }
  342. HRESULT
  343. NdsTypeToAdsTypeCopyNDSSynId15(
  344. PNDSOBJECT lpNdsSrcObject,
  345. PADSVALUE lpAdsDestValue
  346. )
  347. {
  348. HRESULT hr = S_OK;
  349. lpAdsDestValue->dwType = ADSTYPE_PATH;
  350. lpAdsDestValue->pPath = (PADS_PATH)AllocADsMem(sizeof(ADS_PATH));
  351. if (!lpAdsDestValue->pPath) {
  352. hr = E_OUTOFMEMORY;
  353. BAIL_ON_FAILURE(hr);
  354. }
  355. lpAdsDestValue->pPath->VolumeName =
  356. AllocADsStr(
  357. lpNdsSrcObject->NdsValue.value_15.VolumeName
  358. );
  359. if (!lpAdsDestValue->pPath->VolumeName) {
  360. hr = E_OUTOFMEMORY;
  361. BAIL_ON_FAILURE(hr);
  362. }
  363. lpAdsDestValue->pPath->Path=
  364. AllocADsStr(
  365. lpNdsSrcObject->NdsValue.value_15.Path
  366. );
  367. if (!lpAdsDestValue->pPath->Path) {
  368. hr = E_OUTOFMEMORY;
  369. BAIL_ON_FAILURE(hr);
  370. }
  371. lpAdsDestValue->pPath->Type =
  372. lpNdsSrcObject->NdsValue.value_15.Type;
  373. error:
  374. RRETURN(hr);
  375. }
  376. HRESULT
  377. NdsTypeToAdsTypeCopyNDSSynId16(
  378. PNDSOBJECT lpNdsSrcObject,
  379. PADSVALUE lpAdsDestValue
  380. )
  381. {
  382. HRESULT hr = S_OK;
  383. DWORD dwCount,dwIter;
  384. lpAdsDestValue->dwType = ADSTYPE_REPLICAPOINTER;
  385. lpAdsDestValue->pReplicaPointer = (PADS_REPLICAPOINTER)AllocADsMem(sizeof(ADS_REPLICAPOINTER));
  386. if (!lpAdsDestValue->pReplicaPointer) {
  387. hr = E_OUTOFMEMORY;
  388. BAIL_ON_FAILURE(hr);
  389. }
  390. lpAdsDestValue->pReplicaPointer->ServerName=
  391. AllocADsStr(
  392. lpNdsSrcObject->NdsValue.value_16.ServerName
  393. );
  394. if (!lpAdsDestValue->pReplicaPointer->ServerName) {
  395. hr = E_OUTOFMEMORY;
  396. BAIL_ON_FAILURE(hr);
  397. }
  398. lpAdsDestValue->pReplicaPointer->ReplicaType =
  399. lpNdsSrcObject->NdsValue.value_16.ReplicaType;
  400. lpAdsDestValue->pReplicaPointer->ReplicaNumber =
  401. lpNdsSrcObject->NdsValue.value_16.ReplicaNumber;
  402. dwCount = lpNdsSrcObject->NdsValue.value_16.Count;
  403. lpAdsDestValue->pReplicaPointer->ReplicaAddressHints =
  404. (PADS_NETADDRESS)AllocADsMem(sizeof(ADS_NETADDRESS)*dwCount);
  405. if (!lpAdsDestValue->pReplicaPointer->ReplicaAddressHints) {
  406. hr = E_OUTOFMEMORY;
  407. BAIL_ON_FAILURE(hr);
  408. }
  409. memset(lpAdsDestValue->pReplicaPointer->ReplicaAddressHints, 0, sizeof(ADS_NETADDRESS)*dwCount);
  410. for ( dwIter = 0; dwIter < dwCount; dwIter++ ) {
  411. (lpAdsDestValue->pReplicaPointer->ReplicaAddressHints+dwIter)->AddressType =
  412. (lpNdsSrcObject->NdsValue.value_16.ReplicaAddressHints+dwIter)->AddressType;
  413. hr = CopyOctetString((lpNdsSrcObject->NdsValue.value_16.ReplicaAddressHints+dwIter)->AddressLength,
  414. (lpNdsSrcObject->NdsValue.value_16.ReplicaAddressHints+dwIter)->Address,
  415. &(lpAdsDestValue->pReplicaPointer->ReplicaAddressHints+dwIter)->AddressLength,
  416. &(lpAdsDestValue->pReplicaPointer->ReplicaAddressHints+dwIter)->Address);
  417. }
  418. lpAdsDestValue->pReplicaPointer->Count = dwCount;
  419. error:
  420. RRETURN(hr);
  421. }
  422. HRESULT
  423. NdsTypeToAdsTypeCopyNDSSynId17(
  424. PNDSOBJECT lpNdsSrcObject,
  425. PADSVALUE lpAdsDestValue
  426. )
  427. {
  428. HRESULT hr;
  429. hr = E_ADS_CANT_CONVERT_DATATYPE;
  430. RRETURN(hr);
  431. }
  432. HRESULT
  433. NdsTypeToAdsTypeCopyNDSSynId18(
  434. PNDSOBJECT lpNdsSrcObject,
  435. PADSVALUE lpAdsDestValue
  436. )
  437. {
  438. HRESULT hr = S_OK;
  439. long i;
  440. lpAdsDestValue->dwType = ADSTYPE_POSTALADDRESS;
  441. lpAdsDestValue->pPostalAddress = (PADS_POSTALADDRESS)AllocADsMem(sizeof(ADS_POSTALADDRESS));
  442. if (!lpAdsDestValue->pPostalAddress) {
  443. hr = E_OUTOFMEMORY;
  444. BAIL_ON_FAILURE(hr);
  445. }
  446. for (i=0;i<6;i++) {
  447. if (lpNdsSrcObject->NdsValue.value_18.PostalAddress[i]) {
  448. lpAdsDestValue->pPostalAddress->PostalAddress[i] =
  449. AllocADsStr(
  450. lpNdsSrcObject->NdsValue.value_18.PostalAddress[i]
  451. );
  452. if (!lpAdsDestValue->pPostalAddress->PostalAddress[i]) {
  453. hr = E_OUTOFMEMORY;
  454. BAIL_ON_FAILURE(hr);
  455. }
  456. }
  457. else {
  458. lpAdsDestValue->pPostalAddress->PostalAddress[i] =
  459. AllocADsStr(
  460. L""
  461. );
  462. if (!lpAdsDestValue->pPostalAddress->PostalAddress[i]) {
  463. hr = E_OUTOFMEMORY;
  464. BAIL_ON_FAILURE(hr);
  465. }
  466. }
  467. }
  468. error:
  469. RRETURN(hr);
  470. }
  471. HRESULT
  472. NdsTypeToAdsTypeCopyNDSSynId19(
  473. PNDSOBJECT lpNdsSrcObject,
  474. PADSVALUE lpAdsDestValue
  475. )
  476. {
  477. HRESULT hr = S_OK;
  478. lpAdsDestValue->dwType = ADSTYPE_TIMESTAMP;
  479. lpAdsDestValue->Timestamp.WholeSeconds =
  480. lpNdsSrcObject->NdsValue.value_19.WholeSeconds;
  481. lpAdsDestValue->Timestamp.EventID =
  482. lpNdsSrcObject->NdsValue.value_19.EventID;
  483. RRETURN(hr);
  484. }
  485. HRESULT
  486. NdsTypeToAdsTypeCopyNDSSynId20(
  487. PNDSOBJECT lpNdsSrcObject,
  488. PADSVALUE lpAdsDestValue
  489. )
  490. {
  491. HRESULT hr = S_OK;
  492. lpAdsDestValue->dwType = ADSTYPE_OBJECT_CLASS;
  493. lpAdsDestValue->ClassName =
  494. AllocADsStr(
  495. lpNdsSrcObject->NdsValue.value_20.ClassName
  496. );
  497. if (!lpAdsDestValue->ClassName) {
  498. hr = E_OUTOFMEMORY;
  499. BAIL_ON_FAILURE(hr);
  500. }
  501. error:
  502. RRETURN(hr);
  503. }
  504. HRESULT
  505. NdsTypeToAdsTypeCopyNDSSynId21(
  506. PNDSOBJECT lpNdsSrcObject,
  507. PADSVALUE lpAdsDestValue
  508. )
  509. {
  510. HRESULT hr = S_OK;
  511. DWORD dwLength = 0;
  512. LPBYTE lpByte = NULL;
  513. lpAdsDestValue->dwType = ADSTYPE_OCTET_STRING;
  514. dwLength = lpNdsSrcObject->NdsValue.value_21.Length;
  515. if (dwLength) {
  516. lpByte = (LPBYTE)AllocADsMem(dwLength);
  517. if (!lpByte) {
  518. hr = E_OUTOFMEMORY;
  519. BAIL_ON_FAILURE(hr);
  520. }
  521. if (lpNdsSrcObject->NdsValue.value_21.Data) {
  522. memcpy(lpByte, lpNdsSrcObject->NdsValue.value_21.Data, dwLength);
  523. }
  524. lpAdsDestValue->OctetString.dwLength = dwLength;
  525. lpAdsDestValue->OctetString.lpValue = lpByte;
  526. }else {
  527. lpAdsDestValue->OctetString.dwLength = 0;
  528. lpAdsDestValue->OctetString.lpValue = NULL;
  529. }
  530. error:
  531. RRETURN(hr);
  532. }
  533. HRESULT
  534. NdsTypeToAdsTypeCopyNDSSynId22(
  535. PNDSOBJECT lpNdsSrcObject,
  536. PADSVALUE lpAdsDestValue
  537. )
  538. {
  539. HRESULT hr = S_OK;
  540. lpAdsDestValue->dwType = ADSTYPE_INTEGER;
  541. lpAdsDestValue->Integer =
  542. lpNdsSrcObject->NdsValue.value_22.Counter;
  543. RRETURN(hr);
  544. }
  545. HRESULT
  546. NdsTypeToAdsTypeCopyNDSSynId23(
  547. PNDSOBJECT lpNdsSrcObject,
  548. PADSVALUE lpAdsDestValue
  549. )
  550. {
  551. HRESULT hr = S_OK;
  552. lpAdsDestValue->dwType = ADSTYPE_BACKLINK;
  553. lpAdsDestValue->BackLink.ObjectName =
  554. AllocADsStr(
  555. lpNdsSrcObject->NdsValue.value_23.ObjectName
  556. );
  557. if (!lpAdsDestValue->BackLink.ObjectName) {
  558. hr = E_OUTOFMEMORY;
  559. BAIL_ON_FAILURE(hr);
  560. }
  561. lpAdsDestValue->BackLink.RemoteID =
  562. lpNdsSrcObject->NdsValue.value_23.RemoteID;
  563. error:
  564. RRETURN(hr);
  565. }
  566. HRESULT
  567. NdsTypeToAdsTypeCopyNDSSynId24(
  568. PNDSOBJECT lpNdsSrcObject,
  569. PADSVALUE lpAdsDestValue
  570. )
  571. {
  572. HRESULT hr = S_OK;
  573. lpAdsDestValue->dwType = ADSTYPE_UTC_TIME;
  574. hr = ConvertDWORDtoSYSTEMTIME(
  575. lpNdsSrcObject->NdsValue.value_24.Time,
  576. &(lpAdsDestValue->UTCTime)
  577. );
  578. RRETURN(hr);
  579. }
  580. HRESULT
  581. NdsTypeToAdsTypeCopyNDSSynId25(
  582. PNDSOBJECT lpNdsSrcObject,
  583. PADSVALUE lpAdsDestValue
  584. )
  585. {
  586. HRESULT hr = S_OK;
  587. lpAdsDestValue->dwType = ADSTYPE_TYPEDNAME;
  588. lpAdsDestValue->pTypedName = (PADS_TYPEDNAME)AllocADsMem(sizeof(ADS_TYPEDNAME));
  589. if (!lpAdsDestValue->pTypedName) {
  590. hr = E_OUTOFMEMORY;
  591. BAIL_ON_FAILURE(hr);
  592. }
  593. lpAdsDestValue->pTypedName->ObjectName=
  594. AllocADsStr(
  595. lpNdsSrcObject->NdsValue.value_25.ObjectName
  596. );
  597. if (!lpAdsDestValue->pTypedName->ObjectName) {
  598. hr = E_OUTOFMEMORY;
  599. BAIL_ON_FAILURE(hr);
  600. }
  601. lpAdsDestValue->pTypedName->Level=
  602. lpNdsSrcObject->NdsValue.value_25.Level;
  603. lpAdsDestValue->pTypedName->Interval=
  604. lpNdsSrcObject->NdsValue.value_25.Interval;
  605. error:
  606. RRETURN(hr);
  607. }
  608. HRESULT
  609. NdsTypeToAdsTypeCopyNDSSynId26(
  610. PNDSOBJECT lpNdsSrcObject,
  611. PADSVALUE lpAdsDestValue
  612. )
  613. {
  614. HRESULT hr = S_OK;
  615. lpAdsDestValue->dwType = ADSTYPE_HOLD;
  616. lpAdsDestValue->Hold.ObjectName=
  617. AllocADsStr(
  618. lpNdsSrcObject->NdsValue.value_26.ObjectName
  619. );
  620. if (!lpAdsDestValue->Hold.ObjectName) {
  621. hr = E_OUTOFMEMORY;
  622. BAIL_ON_FAILURE(hr);
  623. }
  624. lpAdsDestValue->Hold.Amount=
  625. lpNdsSrcObject->NdsValue.value_26.Amount;
  626. error:
  627. RRETURN(hr);
  628. }
  629. HRESULT
  630. NdsTypeToAdsTypeCopyNDSSynId27(
  631. PNDSOBJECT lpNdsSrcObject,
  632. PADSVALUE lpAdsDestValue
  633. )
  634. {
  635. HRESULT hr = S_OK;
  636. lpAdsDestValue->dwType = ADSTYPE_INTEGER;
  637. lpAdsDestValue->Integer =
  638. lpNdsSrcObject->NdsValue.value_27.Interval;
  639. RRETURN(hr);
  640. }
  641. HRESULT
  642. NdsTypeToAdsTypeCopy(
  643. PNDSOBJECT lpNdsSrcObject,
  644. PADSVALUE lpAdsDestValue
  645. )
  646. {
  647. HRESULT hr = S_OK;
  648. switch (lpNdsSrcObject->NdsType) {
  649. case 1:
  650. hr = NdsTypeToAdsTypeCopyNDSSynId1(
  651. lpNdsSrcObject,
  652. lpAdsDestValue
  653. );
  654. break;
  655. case 2:
  656. hr = NdsTypeToAdsTypeCopyNDSSynId2(
  657. lpNdsSrcObject,
  658. lpAdsDestValue
  659. );
  660. break;
  661. case 3:
  662. hr = NdsTypeToAdsTypeCopyNDSSynId3(
  663. lpNdsSrcObject,
  664. lpAdsDestValue
  665. );
  666. break;
  667. case 4:
  668. hr = NdsTypeToAdsTypeCopyNDSSynId4(
  669. lpNdsSrcObject,
  670. lpAdsDestValue
  671. );
  672. break;
  673. case 5:
  674. hr = NdsTypeToAdsTypeCopyNDSSynId5(
  675. lpNdsSrcObject,
  676. lpAdsDestValue
  677. );
  678. break;
  679. case 6:
  680. hr = NdsTypeToAdsTypeCopyNDSSynId6(
  681. lpNdsSrcObject,
  682. lpAdsDestValue
  683. );
  684. break;
  685. case 7:
  686. hr = NdsTypeToAdsTypeCopyNDSSynId7(
  687. lpNdsSrcObject,
  688. lpAdsDestValue
  689. );
  690. break;
  691. case 8:
  692. hr = NdsTypeToAdsTypeCopyNDSSynId8(
  693. lpNdsSrcObject,
  694. lpAdsDestValue
  695. );
  696. break;
  697. case 9:
  698. hr = NdsTypeToAdsTypeCopyNDSSynId9(
  699. lpNdsSrcObject,
  700. lpAdsDestValue
  701. );
  702. break;
  703. case 10:
  704. hr = NdsTypeToAdsTypeCopyNDSSynId10(
  705. lpNdsSrcObject,
  706. lpAdsDestValue
  707. );
  708. break;
  709. case 11:
  710. hr = NdsTypeToAdsTypeCopyNDSSynId11(
  711. lpNdsSrcObject,
  712. lpAdsDestValue
  713. );
  714. break;
  715. case 12:
  716. hr = NdsTypeToAdsTypeCopyNDSSynId12(
  717. lpNdsSrcObject,
  718. lpAdsDestValue
  719. );
  720. break;
  721. case 13:
  722. hr = NdsTypeToAdsTypeCopyNDSSynId13(
  723. lpNdsSrcObject,
  724. lpAdsDestValue
  725. );
  726. break;
  727. case 14:
  728. hr = NdsTypeToAdsTypeCopyNDSSynId14(
  729. lpNdsSrcObject,
  730. lpAdsDestValue
  731. );
  732. break;
  733. case 15:
  734. hr = NdsTypeToAdsTypeCopyNDSSynId15(
  735. lpNdsSrcObject,
  736. lpAdsDestValue
  737. );
  738. break;
  739. case 16:
  740. hr = NdsTypeToAdsTypeCopyNDSSynId16(
  741. lpNdsSrcObject,
  742. lpAdsDestValue
  743. );
  744. break;
  745. case 17:
  746. hr = NdsTypeToAdsTypeCopyNDSSynId17(
  747. lpNdsSrcObject,
  748. lpAdsDestValue
  749. );
  750. break;
  751. case 18:
  752. hr = NdsTypeToAdsTypeCopyNDSSynId18(
  753. lpNdsSrcObject,
  754. lpAdsDestValue
  755. );
  756. break;
  757. case 19:
  758. hr = NdsTypeToAdsTypeCopyNDSSynId19(
  759. lpNdsSrcObject,
  760. lpAdsDestValue
  761. );
  762. break;
  763. case 20:
  764. hr = NdsTypeToAdsTypeCopyNDSSynId20(
  765. lpNdsSrcObject,
  766. lpAdsDestValue
  767. );
  768. break;
  769. case 21:
  770. hr = NdsTypeToAdsTypeCopyNDSSynId21(
  771. lpNdsSrcObject,
  772. lpAdsDestValue
  773. );
  774. break;
  775. case 22:
  776. hr = NdsTypeToAdsTypeCopyNDSSynId22(
  777. lpNdsSrcObject,
  778. lpAdsDestValue
  779. );
  780. break;
  781. case 23:
  782. hr = NdsTypeToAdsTypeCopyNDSSynId23(
  783. lpNdsSrcObject,
  784. lpAdsDestValue
  785. );
  786. break;
  787. case 24:
  788. hr = NdsTypeToAdsTypeCopyNDSSynId24(
  789. lpNdsSrcObject,
  790. lpAdsDestValue
  791. );
  792. break;
  793. case 25:
  794. hr = NdsTypeToAdsTypeCopyNDSSynId25(
  795. lpNdsSrcObject,
  796. lpAdsDestValue
  797. );
  798. break;
  799. case 26:
  800. hr = NdsTypeToAdsTypeCopyNDSSynId26(
  801. lpNdsSrcObject,
  802. lpAdsDestValue
  803. );
  804. break;
  805. case 27:
  806. hr = NdsTypeToAdsTypeCopyNDSSynId27(
  807. lpNdsSrcObject,
  808. lpAdsDestValue
  809. );
  810. break;
  811. default:
  812. hr = E_FAIL;
  813. break;
  814. }
  815. RRETURN(hr);
  816. }
  817. HRESULT
  818. NdsTypeToAdsTypeCopyConstruct(
  819. LPNDSOBJECT pNdsSrcObjects,
  820. DWORD dwNumObjects,
  821. LPADSVALUE * ppAdsDestValues
  822. )
  823. {
  824. DWORD i = 0;
  825. LPADSVALUE pAdsDestValues = NULL;
  826. HRESULT hr = S_OK;
  827. pAdsDestValues = (LPADSVALUE)AllocADsMem(
  828. dwNumObjects * sizeof(ADSVALUE)
  829. );
  830. if (!pAdsDestValues) {
  831. RRETURN(E_FAIL);
  832. }
  833. for (i = 0; i < dwNumObjects; i++ ) {
  834. hr = NdsTypeToAdsTypeCopy(
  835. pNdsSrcObjects + i,
  836. pAdsDestValues + i
  837. );
  838. BAIL_ON_FAILURE(hr);
  839. }
  840. *ppAdsDestValues = pAdsDestValues;
  841. RRETURN(S_OK);
  842. error:
  843. if (pAdsDestValues) {
  844. AdsFreeAdsValues(
  845. pAdsDestValues,
  846. dwNumObjects
  847. );
  848. FreeADsMem(pAdsDestValues);
  849. }
  850. *ppAdsDestValues = NULL;
  851. RRETURN(hr);
  852. }