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.

862 lines
14 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ndsfree.cxx
  7. //
  8. // Contents: NDS Object Free Routines
  9. //
  10. // Functions:
  11. //
  12. // History: 25-Apr-96 KrishnaG Created.
  13. //
  14. // Object Types 6, 13, 16, and 21 are flaky - pay extra attn.
  15. //
  16. //
  17. //----------------------------------------------------------------------------
  18. #include "nds.hxx"
  19. //
  20. // NdsType objects free code
  21. //
  22. HRESULT
  23. NdsTypeFreeNDSSynId1(
  24. PNDSOBJECT lpNdsDestObject
  25. )
  26. {
  27. HRESULT hr = S_OK;
  28. FreeADsStr(lpNdsDestObject->NdsValue.value_1.DNString);
  29. RRETURN(hr);
  30. }
  31. HRESULT
  32. NdsTypeFreeNDSSynId2(
  33. PNDSOBJECT lpNdsDestObject
  34. )
  35. {
  36. HRESULT hr = S_OK;
  37. FreeADsStr(lpNdsDestObject->NdsValue.value_1.DNString);
  38. RRETURN(hr);
  39. }
  40. HRESULT
  41. NdsTypeFreeNDSSynId3(
  42. PNDSOBJECT lpNdsDestObject
  43. )
  44. {
  45. HRESULT hr = S_OK;
  46. FreeADsStr(lpNdsDestObject->NdsValue.value_1.DNString);
  47. RRETURN(hr);
  48. }
  49. HRESULT
  50. NdsTypeFreeNDSSynId4(
  51. PNDSOBJECT lpNdsDestObject
  52. )
  53. {
  54. HRESULT hr = S_OK;
  55. FreeADsStr(lpNdsDestObject->NdsValue.value_1.DNString);
  56. RRETURN(hr);
  57. }
  58. HRESULT
  59. NdsTypeFreeNDSSynId5(
  60. PNDSOBJECT lpNdsDestObject
  61. )
  62. {
  63. HRESULT hr = S_OK;
  64. FreeADsStr(lpNdsDestObject->NdsValue.value_1.DNString);
  65. RRETURN(hr);
  66. }
  67. HRESULT
  68. NdsTypeFreeNDSSynId6(
  69. PNDSOBJECT lpNdsDestObject
  70. )
  71. {
  72. HRESULT hr = S_OK;
  73. LPNDS_ASN1_TYPE_6 pStart = NULL;
  74. LPNDS_ASN1_TYPE_6 pTemp = NULL;
  75. FreeADsStr(lpNdsDestObject->NdsValue.value_6.String);
  76. pStart = lpNdsDestObject->NdsValue.value_6.Next;
  77. while (pStart){
  78. pTemp = pStart;
  79. pStart = pTemp->Next;
  80. FreeADsStr(pTemp->String);
  81. FreeADsMem(pTemp);
  82. }
  83. RRETURN(hr);
  84. }
  85. HRESULT
  86. NdsTypeFreeNDSSynId7(
  87. PNDSOBJECT lpNdsDestObject
  88. )
  89. {
  90. HRESULT hr = S_OK;
  91. //
  92. // Do Nothing - Boolean
  93. //
  94. RRETURN(hr);
  95. }
  96. HRESULT
  97. NdsTypeFreeNDSSynId8(
  98. PNDSOBJECT lpNdsDestObject
  99. )
  100. {
  101. HRESULT hr = S_OK;
  102. //
  103. // Do nothing - Integer
  104. //
  105. RRETURN(hr);
  106. }
  107. HRESULT
  108. NdsTypeFreeNDSSynId9(
  109. PNDSOBJECT lpNdsDestObject
  110. )
  111. {
  112. HRESULT hr = S_OK;
  113. DWORD Length = 0;
  114. LPBYTE pBuffer = NULL;
  115. if (lpNdsDestObject->NdsValue.value_9.OctetString) {
  116. FreeADsMem(
  117. lpNdsDestObject->NdsValue.value_9.OctetString
  118. );
  119. }
  120. RRETURN(hr);
  121. }
  122. HRESULT
  123. NdsTypeFreeNDSSynId10(
  124. PNDSOBJECT lpNdsDestObject
  125. )
  126. {
  127. HRESULT hr = S_OK;
  128. FreeADsStr(lpNdsDestObject->NdsValue.value_10.TelephoneNumber);
  129. RRETURN(hr);
  130. }
  131. HRESULT
  132. NdsTypeFreeNDSSynId11(
  133. PNDSOBJECT lpNdsDestObject
  134. )
  135. {
  136. HRESULT hr = S_OK;
  137. FreeADsStr(lpNdsDestObject->NdsValue.value_11.TelephoneNumber);
  138. RRETURN(hr);
  139. }
  140. HRESULT
  141. NdsTypeFreeNDSSynId12(
  142. PNDSOBJECT lpNdsDestObject
  143. )
  144. {
  145. HRESULT hr = S_OK;
  146. if (lpNdsDestObject->NdsValue.value_12.Address) {
  147. FreeADsMem(lpNdsDestObject->NdsValue.value_12.Address);
  148. }
  149. RRETURN(hr);
  150. }
  151. HRESULT
  152. NdsTypeFreeNDSSynId13(
  153. PNDSOBJECT lpNdsDestObject
  154. )
  155. {
  156. //
  157. // BugBug 13 Leaks like a sieve!!
  158. //
  159. HRESULT hr = S_OK;
  160. LPNDS_ASN1_TYPE_13 pStart = NULL;
  161. LPNDS_ASN1_TYPE_13 pTemp = NULL;
  162. if (lpNdsDestObject->NdsValue.value_13.Data) {
  163. FreeADsMem(lpNdsDestObject->NdsValue.value_13.Data);
  164. }
  165. pStart = lpNdsDestObject->NdsValue.value_13.Next;
  166. while (pStart){
  167. pTemp = pStart;
  168. pStart = pTemp->Next;
  169. if (pTemp->Data) {
  170. FreeADsMem(pTemp->Data);
  171. }
  172. FreeADsMem(pTemp);
  173. }
  174. RRETURN(hr);
  175. }
  176. HRESULT
  177. NdsTypeFreeNDSSynId14(
  178. PNDSOBJECT lpNdsDestObject
  179. )
  180. {
  181. HRESULT hr = S_OK;
  182. FreeADsStr(lpNdsDestObject->NdsValue.value_14.Address);
  183. RRETURN(hr);
  184. }
  185. HRESULT
  186. NdsTypeFreeNDSSynId15(
  187. PNDSOBJECT lpNdsDestObject
  188. )
  189. {
  190. HRESULT hr = S_OK;
  191. FreeADsStr(lpNdsDestObject->NdsValue.value_15.VolumeName);
  192. FreeADsStr(lpNdsDestObject->NdsValue.value_15.Path);
  193. RRETURN(hr);
  194. }
  195. HRESULT
  196. NdsTypeFreeNDSSynId16(
  197. PNDSOBJECT lpNdsDestObject
  198. )
  199. {
  200. HRESULT hr = S_OK;
  201. DWORD dwCount = 0;
  202. DWORD i = 0;
  203. LPNDS_ASN1_TYPE_12 lpNdsTempASN1_12 = NULL;
  204. FreeADsStr(lpNdsDestObject->NdsValue.value_16.ServerName);
  205. dwCount = lpNdsDestObject->NdsValue.value_16.Count;
  206. lpNdsTempASN1_12 = lpNdsDestObject->NdsValue.value_16.ReplicaAddressHints;
  207. for (i = 0; i < dwCount; i++) {
  208. if ((lpNdsTempASN1_12 + i)->Address) {
  209. FreeADsMem((lpNdsTempASN1_12 + i)->Address);
  210. }
  211. }
  212. FreeADsMem(lpNdsTempASN1_12);
  213. RRETURN(hr);
  214. }
  215. HRESULT
  216. NdsTypeFreeNDSSynId17(
  217. PNDSOBJECT lpNdsDestObject
  218. )
  219. {
  220. HRESULT hr = S_OK;
  221. FreeADsStr(lpNdsDestObject->NdsValue.value_17.ProtectedAttrName);
  222. FreeADsStr(lpNdsDestObject->NdsValue.value_17.SubjectName);
  223. RRETURN(hr);
  224. }
  225. HRESULT
  226. NdsTypeFreeNDSSynId18(
  227. PNDSOBJECT lpNdsDestObject
  228. )
  229. {
  230. HRESULT hr = S_OK;
  231. DWORD i = 0;
  232. for (i = 0; i < 6; i++) {
  233. FreeADsStr(lpNdsDestObject->NdsValue.value_18.PostalAddress[i]);
  234. }
  235. RRETURN(hr);
  236. }
  237. HRESULT
  238. NdsTypeFreeNDSSynId19(
  239. PNDSOBJECT lpNdsDestObject
  240. )
  241. {
  242. HRESULT hr = S_OK;
  243. //
  244. // Do nothing for 19
  245. //
  246. RRETURN(hr);
  247. }
  248. HRESULT
  249. NdsTypeFreeNDSSynId20(
  250. PNDSOBJECT lpNdsDestObject
  251. )
  252. {
  253. HRESULT hr = S_OK;
  254. FreeADsStr(lpNdsDestObject->NdsValue.value_20.ClassName);
  255. RRETURN(hr);
  256. }
  257. HRESULT
  258. NdsTypeFreeNDSSynId21(
  259. PNDSOBJECT lpNdsDestObject
  260. )
  261. {
  262. HRESULT hr = S_OK;
  263. //
  264. // BugBug - how do we handle this byte stream!!
  265. //
  266. //
  267. // BugBug 21 -still don't know how to handle this
  268. //
  269. RRETURN(hr);
  270. }
  271. HRESULT
  272. NdsTypeFreeNDSSynId22(
  273. PNDSOBJECT lpNdsDestObject
  274. )
  275. {
  276. HRESULT hr = S_OK;
  277. //
  278. // DoNothing for 22
  279. //
  280. RRETURN(hr);
  281. }
  282. HRESULT
  283. NdsTypeFreeNDSSynId23(
  284. PNDSOBJECT lpNdsDestObject
  285. )
  286. {
  287. HRESULT hr = S_OK;
  288. FreeADsStr(lpNdsDestObject->NdsValue.value_23.ObjectName);
  289. RRETURN(hr);
  290. }
  291. HRESULT
  292. NdsTypeFreeNDSSynId24(
  293. PNDSOBJECT lpNdsDestObject
  294. )
  295. {
  296. HRESULT hr = S_OK;
  297. //
  298. // Do nothing
  299. //
  300. RRETURN(hr);
  301. }
  302. HRESULT
  303. NdsTypeFreeNDSSynId25(
  304. PNDSOBJECT lpNdsDestObject
  305. )
  306. {
  307. HRESULT hr = S_OK;
  308. FreeADsStr(lpNdsDestObject->NdsValue.value_25.ObjectName);
  309. RRETURN(hr);
  310. }
  311. HRESULT
  312. NdsTypeFreeNDSSynId26(
  313. PNDSOBJECT lpNdsDestObject
  314. )
  315. {
  316. HRESULT hr = S_OK;
  317. FreeADsStr(lpNdsDestObject->NdsValue.value_26.ObjectName);
  318. RRETURN(hr);
  319. }
  320. HRESULT
  321. NdsTypeFreeNDSSynId27(
  322. PNDSOBJECT lpNdsDestObject
  323. )
  324. {
  325. HRESULT hr = S_OK;
  326. //
  327. // Nothing to do for this one
  328. //
  329. RRETURN(hr);
  330. }
  331. HRESULT
  332. NdsTypeClear(
  333. PNDSOBJECT lpNdsDestObject
  334. )
  335. {
  336. HRESULT hr = S_OK;
  337. switch (lpNdsDestObject->NdsType) {
  338. case 1:
  339. hr = NdsTypeFreeNDSSynId1(
  340. lpNdsDestObject
  341. );
  342. break;
  343. case 2:
  344. hr = NdsTypeFreeNDSSynId2(
  345. lpNdsDestObject
  346. );
  347. break;
  348. case 3:
  349. hr = NdsTypeFreeNDSSynId3(
  350. lpNdsDestObject
  351. );
  352. break;
  353. case 4:
  354. hr = NdsTypeFreeNDSSynId4(
  355. lpNdsDestObject
  356. );
  357. break;
  358. case 5:
  359. hr = NdsTypeFreeNDSSynId5(
  360. lpNdsDestObject
  361. );
  362. break;
  363. case 6:
  364. hr = NdsTypeFreeNDSSynId6(
  365. lpNdsDestObject
  366. );
  367. break;
  368. case 7:
  369. hr = NdsTypeFreeNDSSynId7(
  370. lpNdsDestObject
  371. );
  372. break;
  373. case 8:
  374. hr = NdsTypeFreeNDSSynId8(
  375. lpNdsDestObject
  376. );
  377. break;
  378. case 9:
  379. hr = NdsTypeFreeNDSSynId9(
  380. lpNdsDestObject
  381. );
  382. break;
  383. case 10:
  384. hr = NdsTypeFreeNDSSynId10(
  385. lpNdsDestObject
  386. );
  387. break;
  388. case 11:
  389. hr = NdsTypeFreeNDSSynId11(
  390. lpNdsDestObject
  391. );
  392. break;
  393. case 12:
  394. hr = NdsTypeFreeNDSSynId12(
  395. lpNdsDestObject
  396. );
  397. break;
  398. case 13:
  399. hr = NdsTypeFreeNDSSynId13(
  400. lpNdsDestObject
  401. );
  402. break;
  403. case 14:
  404. hr = NdsTypeFreeNDSSynId14(
  405. lpNdsDestObject
  406. );
  407. break;
  408. case 15:
  409. hr = NdsTypeFreeNDSSynId15(
  410. lpNdsDestObject
  411. );
  412. break;
  413. case 16:
  414. hr = NdsTypeFreeNDSSynId16(
  415. lpNdsDestObject
  416. );
  417. break;
  418. case 17:
  419. hr = NdsTypeFreeNDSSynId17(
  420. lpNdsDestObject
  421. );
  422. break;
  423. case 18:
  424. hr = NdsTypeFreeNDSSynId18(
  425. lpNdsDestObject
  426. );
  427. break;
  428. case 19:
  429. hr = NdsTypeFreeNDSSynId19(
  430. lpNdsDestObject
  431. );
  432. break;
  433. case 20:
  434. hr = NdsTypeFreeNDSSynId20(
  435. lpNdsDestObject
  436. );
  437. break;
  438. case 21:
  439. hr = NdsTypeFreeNDSSynId21(
  440. lpNdsDestObject
  441. );
  442. break;
  443. case 22:
  444. hr = NdsTypeFreeNDSSynId22(
  445. lpNdsDestObject
  446. );
  447. break;
  448. case 23:
  449. hr = NdsTypeFreeNDSSynId23(
  450. lpNdsDestObject
  451. );
  452. break;
  453. case 24:
  454. hr = NdsTypeFreeNDSSynId24(
  455. lpNdsDestObject
  456. );
  457. break;
  458. case 25:
  459. hr = NdsTypeFreeNDSSynId25(
  460. lpNdsDestObject
  461. );
  462. break;
  463. case 26:
  464. hr = NdsTypeFreeNDSSynId26(
  465. lpNdsDestObject
  466. );
  467. break;
  468. case 27:
  469. hr = NdsTypeFreeNDSSynId27(
  470. lpNdsDestObject
  471. );
  472. break;
  473. default:
  474. hr = E_FAIL;
  475. break;
  476. }
  477. RRETURN(hr);
  478. }
  479. void
  480. NdsTypeFreeNdsObjects(
  481. PNDSOBJECT pNdsObject,
  482. DWORD dwNumValues
  483. )
  484. {
  485. DWORD i = 0;
  486. for (i = 0; i < dwNumValues; i++ ) {
  487. NdsTypeClear(pNdsObject + i);
  488. }
  489. FreeADsMem(pNdsObject);
  490. return;
  491. }
  492. HRESULT
  493. FreeNdsValues(
  494. nuint32 luSyntax,
  495. void *attrVal,
  496. nuint32 luAttrValSize
  497. )
  498. {
  499. HRESULT hr = S_OK;
  500. switch (luSyntax) {
  501. case 1:
  502. case 2:
  503. case 3:
  504. case 4:
  505. case 5:
  506. FreeADsMem(attrVal);
  507. break;
  508. case 6: {
  509. pCI_List_T pCurr = (pCI_List_T) attrVal, pTemp = NULL;
  510. FreeADsMem(pCurr->s);
  511. pCurr = pCurr->next;
  512. while (pCurr) {
  513. pTemp = pCurr;
  514. pCurr = pCurr->next;
  515. FreeADsMem(pTemp->s);
  516. FreeADsMem(pTemp);
  517. }
  518. FreeADsMem(attrVal);
  519. break;
  520. }
  521. case 7:
  522. case 8:
  523. FreeADsMem(attrVal);
  524. break;
  525. case 9: {
  526. pOctet_String_T pOctetString = (pOctet_String_T) attrVal;
  527. FreeADsMem(pOctetString->data);
  528. FreeADsMem(pOctetString);
  529. break;
  530. }
  531. case 10:
  532. FreeADsMem(attrVal);
  533. break;
  534. case 11: {
  535. pFax_Number_T pFaxNumber = (pFax_Number_T) attrVal;
  536. FreeADsMem(pFaxNumber->telephoneNumber);
  537. FreeADsMem(pFaxNumber->parameters.data);
  538. FreeADsMem(pFaxNumber);
  539. break;
  540. }
  541. case 12: {
  542. pNet_Address_T pNetAddress = (pNet_Address_T) attrVal;
  543. FreeADsMem(pNetAddress->address);
  544. FreeADsMem(pNetAddress);
  545. break;
  546. }
  547. case 13: {
  548. pOctet_List_T pCurr = (pOctet_List_T) attrVal, pTemp = NULL;
  549. FreeADsMem(pCurr->data);
  550. pCurr = pCurr->next;
  551. while (pCurr) {
  552. pTemp = pCurr;
  553. pCurr = pCurr->next;
  554. FreeADsMem(pTemp->data);
  555. FreeADsMem(pTemp);
  556. }
  557. FreeADsMem(attrVal);
  558. break;
  559. }
  560. case 14: {
  561. pEMail_Address_T pEMailAddress = (pEMail_Address_T) attrVal;
  562. FreeADsMem(pEMailAddress->address);
  563. FreeADsMem(pEMailAddress);
  564. break;
  565. }
  566. case 15: {
  567. pPath_T pPath = (pPath_T) attrVal;
  568. FreeADsMem(pPath->path);
  569. FreeADsMem(pPath->volumeName);
  570. FreeADsMem(pPath);
  571. break;
  572. }
  573. case 16: {
  574. pReplica_Pointer_T pReplicaPointer = (pReplica_Pointer_T) attrVal;
  575. FreeADsMem(pReplicaPointer->serverName);
  576. for (DWORD i=0; i < pReplicaPointer->count; i++) {
  577. FreeADsMem(pReplicaPointer->replicaAddressHint[i].address);
  578. }
  579. FreeADsMem(pReplicaPointer);
  580. break;
  581. }
  582. case 17: {
  583. pObject_ACL_T pObjectACL = (pObject_ACL_T) attrVal;
  584. FreeADsMem(pObjectACL->protectedAttrName);
  585. FreeADsMem(pObjectACL->subjectName);
  586. FreeADsMem(pObjectACL);
  587. break;
  588. }
  589. case 18: {
  590. LPWSTR *pPostalAddresses = (LPWSTR *) attrVal;
  591. for (DWORD i=0; i<6; i++) {
  592. FreeADsMem(pPostalAddresses[i]);
  593. }
  594. FreeADsMem(pPostalAddresses);
  595. break;
  596. }
  597. case 19:
  598. FreeADsMem(attrVal);
  599. break;
  600. case 20:
  601. FreeADsMem(attrVal);
  602. break;
  603. case 21:
  604. //
  605. // Bugbug: more processing might be needed.
  606. //
  607. FreeADsMem(attrVal);
  608. break;
  609. case 22:
  610. FreeADsMem(attrVal);
  611. break;
  612. case 23: {
  613. pBack_Link_T pBackLink = (pBack_Link_T) attrVal;
  614. FreeADsMem(pBackLink->objectName);
  615. FreeADsMem(pBackLink);
  616. break;
  617. }
  618. case 24:
  619. FreeADsMem(attrVal);
  620. break;
  621. case 25: {
  622. pTyped_Name_T pTypedName = (pTyped_Name_T) attrVal;
  623. FreeADsMem(pTypedName->objectName);
  624. FreeADsMem(pTypedName);
  625. break;
  626. }
  627. case 26: {
  628. pHold_T pHold = (pHold_T) attrVal;
  629. FreeADsMem(pHold->objectName);
  630. FreeADsMem(pHold);
  631. break;
  632. }
  633. case 27:
  634. FreeADsMem(attrVal);
  635. break;
  636. default:
  637. hr = E_FAIL;
  638. break;
  639. }
  640. RRETURN(hr);
  641. }