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.

658 lines
11 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. HRESULT hr = S_OK;
  157. LPNDS_ASN1_TYPE_13 pStart = NULL;
  158. LPNDS_ASN1_TYPE_13 pTemp = NULL;
  159. if (lpNdsDestObject->NdsValue.value_13.Data) {
  160. FreeADsMem(lpNdsDestObject->NdsValue.value_13.Data);
  161. }
  162. pStart = lpNdsDestObject->NdsValue.value_13.Next;
  163. while (pStart){
  164. pTemp = pStart;
  165. pStart = pTemp->Next;
  166. if (pTemp->Data) {
  167. FreeADsMem(pTemp->Data);
  168. }
  169. FreeADsMem(pTemp);
  170. }
  171. RRETURN(hr);
  172. }
  173. HRESULT
  174. NdsTypeFreeNDSSynId14(
  175. PNDSOBJECT lpNdsDestObject
  176. )
  177. {
  178. HRESULT hr = S_OK;
  179. FreeADsStr(lpNdsDestObject->NdsValue.value_14.Address);
  180. RRETURN(hr);
  181. }
  182. HRESULT
  183. NdsTypeFreeNDSSynId15(
  184. PNDSOBJECT lpNdsDestObject
  185. )
  186. {
  187. HRESULT hr = S_OK;
  188. FreeADsStr(lpNdsDestObject->NdsValue.value_15.VolumeName);
  189. FreeADsStr(lpNdsDestObject->NdsValue.value_15.Path);
  190. RRETURN(hr);
  191. }
  192. HRESULT
  193. NdsTypeFreeNDSSynId16(
  194. PNDSOBJECT lpNdsDestObject
  195. )
  196. {
  197. HRESULT hr = S_OK;
  198. DWORD dwCount = 0;
  199. DWORD i = 0;
  200. LPNDS_ASN1_TYPE_12 lpNdsTempASN1_12 = NULL;
  201. FreeADsStr(lpNdsDestObject->NdsValue.value_16.ServerName);
  202. dwCount = lpNdsDestObject->NdsValue.value_16.Count;
  203. lpNdsTempASN1_12 = lpNdsDestObject->NdsValue.value_16.ReplicaAddressHints;
  204. for (i = 0; i < dwCount; i++) {
  205. if ((lpNdsTempASN1_12 + i)->Address) {
  206. FreeADsMem((lpNdsTempASN1_12 + i)->Address);
  207. }
  208. }
  209. FreeADsMem(lpNdsTempASN1_12);
  210. RRETURN(hr);
  211. }
  212. HRESULT
  213. NdsTypeFreeNDSSynId17(
  214. PNDSOBJECT lpNdsDestObject
  215. )
  216. {
  217. HRESULT hr = S_OK;
  218. FreeADsStr(lpNdsDestObject->NdsValue.value_17.ProtectedAttrName);
  219. FreeADsStr(lpNdsDestObject->NdsValue.value_17.SubjectName);
  220. RRETURN(hr);
  221. }
  222. HRESULT
  223. NdsTypeFreeNDSSynId18(
  224. PNDSOBJECT lpNdsDestObject
  225. )
  226. {
  227. HRESULT hr = S_OK;
  228. DWORD i = 0;
  229. for (i = 0; i < 6; i++) {
  230. FreeADsStr(lpNdsDestObject->NdsValue.value_18.PostalAddress[i]);
  231. }
  232. RRETURN(hr);
  233. }
  234. HRESULT
  235. NdsTypeFreeNDSSynId19(
  236. PNDSOBJECT lpNdsDestObject
  237. )
  238. {
  239. HRESULT hr = S_OK;
  240. //
  241. // Do nothing for 19
  242. //
  243. RRETURN(hr);
  244. }
  245. HRESULT
  246. NdsTypeFreeNDSSynId20(
  247. PNDSOBJECT lpNdsDestObject
  248. )
  249. {
  250. HRESULT hr = S_OK;
  251. FreeADsStr(lpNdsDestObject->NdsValue.value_20.ClassName);
  252. RRETURN(hr);
  253. }
  254. HRESULT
  255. NdsTypeFreeNDSSynId21(
  256. PNDSOBJECT lpNdsDestObject
  257. )
  258. {
  259. HRESULT hr = S_OK;
  260. if (lpNdsDestObject->NdsValue.value_21.Data) {
  261. FreeADsMem(
  262. lpNdsDestObject->NdsValue.value_21.Data
  263. );
  264. }
  265. RRETURN(hr);
  266. }
  267. HRESULT
  268. NdsTypeFreeNDSSynId22(
  269. PNDSOBJECT lpNdsDestObject
  270. )
  271. {
  272. HRESULT hr = S_OK;
  273. //
  274. // DoNothing for 22
  275. //
  276. RRETURN(hr);
  277. }
  278. HRESULT
  279. NdsTypeFreeNDSSynId23(
  280. PNDSOBJECT lpNdsDestObject
  281. )
  282. {
  283. HRESULT hr = S_OK;
  284. FreeADsStr(lpNdsDestObject->NdsValue.value_23.ObjectName);
  285. RRETURN(hr);
  286. }
  287. HRESULT
  288. NdsTypeFreeNDSSynId24(
  289. PNDSOBJECT lpNdsDestObject
  290. )
  291. {
  292. HRESULT hr = S_OK;
  293. //
  294. // Do nothing
  295. //
  296. RRETURN(hr);
  297. }
  298. HRESULT
  299. NdsTypeFreeNDSSynId25(
  300. PNDSOBJECT lpNdsDestObject
  301. )
  302. {
  303. HRESULT hr = S_OK;
  304. FreeADsStr(lpNdsDestObject->NdsValue.value_25.ObjectName);
  305. RRETURN(hr);
  306. }
  307. HRESULT
  308. NdsTypeFreeNDSSynId26(
  309. PNDSOBJECT lpNdsDestObject
  310. )
  311. {
  312. HRESULT hr = S_OK;
  313. FreeADsStr(lpNdsDestObject->NdsValue.value_26.ObjectName);
  314. RRETURN(hr);
  315. }
  316. HRESULT
  317. NdsTypeFreeNDSSynId27(
  318. PNDSOBJECT lpNdsDestObject
  319. )
  320. {
  321. HRESULT hr = S_OK;
  322. //
  323. // Nothing to do for this one
  324. //
  325. RRETURN(hr);
  326. }
  327. HRESULT
  328. NdsTypeClear(
  329. PNDSOBJECT lpNdsDestObject
  330. )
  331. {
  332. HRESULT hr = S_OK;
  333. switch (lpNdsDestObject->NdsType) {
  334. case 1:
  335. hr = NdsTypeFreeNDSSynId1(
  336. lpNdsDestObject
  337. );
  338. break;
  339. case 2:
  340. hr = NdsTypeFreeNDSSynId2(
  341. lpNdsDestObject
  342. );
  343. break;
  344. case 3:
  345. hr = NdsTypeFreeNDSSynId3(
  346. lpNdsDestObject
  347. );
  348. break;
  349. case 4:
  350. hr = NdsTypeFreeNDSSynId4(
  351. lpNdsDestObject
  352. );
  353. break;
  354. case 5:
  355. hr = NdsTypeFreeNDSSynId5(
  356. lpNdsDestObject
  357. );
  358. break;
  359. case 6:
  360. hr = NdsTypeFreeNDSSynId6(
  361. lpNdsDestObject
  362. );
  363. break;
  364. case 7:
  365. hr = NdsTypeFreeNDSSynId7(
  366. lpNdsDestObject
  367. );
  368. break;
  369. case 8:
  370. hr = NdsTypeFreeNDSSynId8(
  371. lpNdsDestObject
  372. );
  373. break;
  374. case 9:
  375. hr = NdsTypeFreeNDSSynId9(
  376. lpNdsDestObject
  377. );
  378. break;
  379. case 10:
  380. hr = NdsTypeFreeNDSSynId10(
  381. lpNdsDestObject
  382. );
  383. break;
  384. case 11:
  385. hr = NdsTypeFreeNDSSynId11(
  386. lpNdsDestObject
  387. );
  388. break;
  389. case 12:
  390. hr = NdsTypeFreeNDSSynId12(
  391. lpNdsDestObject
  392. );
  393. break;
  394. case 13:
  395. hr = NdsTypeFreeNDSSynId13(
  396. lpNdsDestObject
  397. );
  398. break;
  399. case 14:
  400. hr = NdsTypeFreeNDSSynId14(
  401. lpNdsDestObject
  402. );
  403. break;
  404. case 15:
  405. hr = NdsTypeFreeNDSSynId15(
  406. lpNdsDestObject
  407. );
  408. break;
  409. case 16:
  410. hr = NdsTypeFreeNDSSynId16(
  411. lpNdsDestObject
  412. );
  413. break;
  414. case 17:
  415. hr = NdsTypeFreeNDSSynId17(
  416. lpNdsDestObject
  417. );
  418. break;
  419. case 18:
  420. hr = NdsTypeFreeNDSSynId18(
  421. lpNdsDestObject
  422. );
  423. break;
  424. case 19:
  425. hr = NdsTypeFreeNDSSynId19(
  426. lpNdsDestObject
  427. );
  428. break;
  429. case 20:
  430. hr = NdsTypeFreeNDSSynId20(
  431. lpNdsDestObject
  432. );
  433. break;
  434. case 21:
  435. hr = NdsTypeFreeNDSSynId21(
  436. lpNdsDestObject
  437. );
  438. break;
  439. case 22:
  440. hr = NdsTypeFreeNDSSynId22(
  441. lpNdsDestObject
  442. );
  443. break;
  444. case 23:
  445. hr = NdsTypeFreeNDSSynId23(
  446. lpNdsDestObject
  447. );
  448. break;
  449. case 24:
  450. hr = NdsTypeFreeNDSSynId24(
  451. lpNdsDestObject
  452. );
  453. break;
  454. case 25:
  455. hr = NdsTypeFreeNDSSynId25(
  456. lpNdsDestObject
  457. );
  458. break;
  459. case 26:
  460. hr = NdsTypeFreeNDSSynId26(
  461. lpNdsDestObject
  462. );
  463. break;
  464. case 27:
  465. hr = NdsTypeFreeNDSSynId27(
  466. lpNdsDestObject
  467. );
  468. break;
  469. default:
  470. hr = E_FAIL;
  471. break;
  472. }
  473. RRETURN(hr);
  474. }
  475. void
  476. NdsTypeFreeNdsObjects(
  477. PNDSOBJECT pNdsObject,
  478. DWORD dwNumValues
  479. )
  480. {
  481. DWORD i = 0;
  482. for (i = 0; i < dwNumValues; i++ ) {
  483. NdsTypeClear(pNdsObject + i);
  484. }
  485. FreeADsMem(pNdsObject);
  486. return;
  487. }