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.

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