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.

641 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ods2nds.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 "nds.hxx"
  18. DWORD
  19. AdsTypeDNStringSize(
  20. PADSVALUE lpAdsSrcValue
  21. )
  22. {
  23. DWORD dwSize = 0;
  24. if(lpAdsSrcValue->dwType != ADSTYPE_DN_STRING){
  25. return(0);
  26. }
  27. dwSize = (wcslen(lpAdsSrcValue->DNString) + 1)*sizeof(WCHAR);
  28. return(dwSize);
  29. }
  30. DWORD
  31. AdsTypeCaseExactStringSize(
  32. PADSVALUE lpAdsSrcValue
  33. )
  34. {
  35. DWORD dwSize = 0;
  36. if(lpAdsSrcValue->dwType != ADSTYPE_CASE_EXACT_STRING){
  37. return(0);
  38. }
  39. dwSize = (wcslen(lpAdsSrcValue->CaseExactString) + 1) *sizeof(WCHAR);
  40. return(dwSize);
  41. }
  42. DWORD
  43. AdsTypeCaseIgnoreStringSize(
  44. PADSVALUE lpAdsSrcValue
  45. )
  46. {
  47. DWORD dwSize = 0;
  48. if(lpAdsSrcValue->dwType != ADSTYPE_CASE_IGNORE_STRING){
  49. return(0);
  50. }
  51. dwSize = (wcslen(lpAdsSrcValue->CaseIgnoreString) + 1) *sizeof(WCHAR);
  52. return(dwSize);
  53. }
  54. DWORD
  55. AdsTypePrintableStringSize(
  56. PADSVALUE lpAdsSrcValue
  57. )
  58. {
  59. DWORD dwSize = 0;
  60. if(lpAdsSrcValue->dwType != ADSTYPE_PRINTABLE_STRING){
  61. return(0);
  62. }
  63. dwSize = (wcslen(lpAdsSrcValue->PrintableString) + 1) *sizeof(WCHAR);
  64. return(dwSize);
  65. }
  66. DWORD
  67. AdsTypeNumericStringSize(
  68. PADSVALUE lpAdsSrcValue
  69. )
  70. {
  71. DWORD dwSize = 0;
  72. if(lpAdsSrcValue->dwType != ADSTYPE_NUMERIC_STRING){
  73. return(0);
  74. }
  75. dwSize = (wcslen(lpAdsSrcValue->NumericString) + 1)* sizeof(WCHAR);
  76. return(dwSize);
  77. }
  78. DWORD
  79. AdsTypeBooleanSize(
  80. PADSVALUE lpAdsSrcValue
  81. )
  82. {
  83. if(lpAdsSrcValue->dwType != ADSTYPE_BOOLEAN){
  84. return(0);
  85. }
  86. return(0);
  87. }
  88. DWORD
  89. AdsTypeIntegerSize(
  90. PADSVALUE lpAdsSrcValue
  91. )
  92. {
  93. DWORD dwSize = 0;
  94. if(lpAdsSrcValue->dwType != ADSTYPE_INTEGER){
  95. return(0);
  96. }
  97. return(0);
  98. }
  99. DWORD
  100. AdsTypeOctetStringSize(
  101. PADSVALUE lpAdsSrcValue
  102. )
  103. {
  104. DWORD dwNumBytes = 0;
  105. if(lpAdsSrcValue->dwType != ADSTYPE_OCTET_STRING){
  106. return(0);
  107. }
  108. dwNumBytes = lpAdsSrcValue->OctetString.dwLength;
  109. return(dwNumBytes);
  110. }
  111. DWORD
  112. AdsTypeTimeSize(
  113. PADSVALUE lpAdsSrcValue
  114. )
  115. {
  116. if(lpAdsSrcValue->dwType != ADSTYPE_UTC_TIME){
  117. return(0);
  118. }
  119. return(0);
  120. }
  121. DWORD
  122. AdsTypeObjectClassSize(
  123. PADSVALUE lpAdsSrcValue
  124. )
  125. {
  126. DWORD dwSize = 0;
  127. if(lpAdsSrcValue->dwType != ADSTYPE_OBJECT_CLASS){
  128. return(0);
  129. }
  130. dwSize = (wcslen(lpAdsSrcValue->ClassName) + 1)*sizeof(WCHAR);
  131. return(dwSize);
  132. }
  133. DWORD
  134. AdsTypeCaseIgnoreListSize(
  135. PADSVALUE lpAdsSrcValue
  136. )
  137. {
  138. DWORD dwSize = 0;
  139. DWORD dwLength = 0;
  140. PADS_CASEIGNORE_LIST pAdsNext = lpAdsSrcValue->pCaseIgnoreList;
  141. if(lpAdsSrcValue->dwType != ADSTYPE_CASEIGNORE_LIST){
  142. return(0);
  143. }
  144. if (lpAdsSrcValue->pCaseIgnoreList == NULL) {
  145. return(0);
  146. }
  147. dwSize += sizeof(ADS_CASEIGNORE_LIST);
  148. dwLength = (wcslen(pAdsNext->String) + 1)*sizeof(WCHAR);
  149. dwSize += dwLength;
  150. pAdsNext = pAdsNext->Next;
  151. while (pAdsNext) {
  152. dwSize += sizeof(ADS_CASEIGNORE_LIST);
  153. dwLength = (wcslen(pAdsNext->String) + 1)*sizeof(WCHAR);
  154. dwSize += dwLength;
  155. pAdsNext = pAdsNext->Next;
  156. }
  157. return(dwSize);
  158. }
  159. DWORD
  160. AdsTypeOctetListSize(
  161. PADSVALUE lpAdsSrcValue
  162. )
  163. {
  164. DWORD dwSize = 0;
  165. DWORD dwNumBytes = 0;
  166. DWORD dwLength = 0;
  167. PADS_OCTET_LIST pAdsNext = lpAdsSrcValue->pOctetList;
  168. if(lpAdsSrcValue->dwType != ADSTYPE_OCTET_LIST){
  169. return(0);
  170. }
  171. if (lpAdsSrcValue->pOctetList == NULL) {
  172. return(0);
  173. }
  174. dwSize += sizeof(ADS_OCTET_LIST);
  175. dwNumBytes = pAdsNext->Length;
  176. dwSize += dwNumBytes;
  177. pAdsNext = pAdsNext->Next;
  178. while (pAdsNext) {
  179. dwSize += sizeof(ADS_OCTET_LIST);
  180. dwNumBytes = pAdsNext->Length;
  181. dwSize += dwNumBytes;
  182. pAdsNext = pAdsNext->Next;
  183. }
  184. return(dwSize);
  185. }
  186. DWORD
  187. AdsTypePathSize(
  188. PADSVALUE lpAdsSrcValue
  189. )
  190. {
  191. DWORD dwSize = 0;
  192. DWORD dwLength = 0;
  193. if(lpAdsSrcValue->dwType != ADSTYPE_PATH){
  194. return(0);
  195. }
  196. if (lpAdsSrcValue->pPath == NULL) {
  197. return(0);
  198. }
  199. dwSize += sizeof(ADS_PATH);
  200. dwLength = (wcslen(lpAdsSrcValue->pPath->VolumeName) + 1)*sizeof(WCHAR);
  201. dwSize += dwLength;
  202. dwLength = (wcslen(lpAdsSrcValue->pPath->Path) + 1)*sizeof(WCHAR);
  203. dwSize += dwLength;
  204. return(dwSize);
  205. }
  206. DWORD
  207. AdsTypePostalAddressSize(
  208. PADSVALUE lpAdsSrcValue
  209. )
  210. {
  211. DWORD dwSize = 0;
  212. DWORD dwLength = 0;
  213. long i;
  214. if(lpAdsSrcValue->dwType != ADSTYPE_POSTALADDRESS){
  215. return(0);
  216. }
  217. if (lpAdsSrcValue->pPostalAddress == NULL) {
  218. return(0);
  219. }
  220. dwSize += sizeof(ADS_POSTALADDRESS);
  221. for (i=0;i<6;i++) {
  222. if (lpAdsSrcValue->pPostalAddress->PostalAddress[i]) {
  223. dwLength = (wcslen(lpAdsSrcValue->pPostalAddress->PostalAddress[i]) + 1)*sizeof(WCHAR);
  224. dwSize += dwLength;
  225. }
  226. else {
  227. dwSize += sizeof(WCHAR);
  228. }
  229. }
  230. return(dwSize);
  231. }
  232. DWORD
  233. AdsTypeTimestampSize(
  234. PADSVALUE lpAdsSrcValue
  235. )
  236. {
  237. DWORD dwSize = 0;
  238. if(lpAdsSrcValue->dwType != ADSTYPE_TIMESTAMP){
  239. return(0);
  240. }
  241. return(dwSize);
  242. }
  243. DWORD
  244. AdsTypeBackLinkSize(
  245. PADSVALUE lpAdsSrcValue
  246. )
  247. {
  248. DWORD dwSize = 0;
  249. DWORD dwLength = 0;
  250. if(lpAdsSrcValue->dwType != ADSTYPE_BACKLINK){
  251. return(0);
  252. }
  253. dwLength = (wcslen(lpAdsSrcValue->BackLink.ObjectName) + 1)*sizeof(WCHAR);
  254. dwSize += dwLength;
  255. return(dwSize);
  256. }
  257. DWORD
  258. AdsTypeTypedNameSize(
  259. PADSVALUE lpAdsSrcValue
  260. )
  261. {
  262. DWORD dwSize = 0;
  263. DWORD dwLength = 0;
  264. if(lpAdsSrcValue->dwType != ADSTYPE_TYPEDNAME){
  265. return(0);
  266. }
  267. if (lpAdsSrcValue->pTypedName == NULL) {
  268. return(0);
  269. }
  270. dwSize += sizeof(ADS_TYPEDNAME);
  271. dwLength = (wcslen(lpAdsSrcValue->pTypedName->ObjectName) + 1)*sizeof(WCHAR);
  272. dwSize += dwLength;
  273. return(dwSize);
  274. }
  275. DWORD
  276. AdsTypeHoldSize(
  277. PADSVALUE lpAdsSrcValue
  278. )
  279. {
  280. DWORD dwSize = 0;
  281. DWORD dwLength = 0;
  282. if(lpAdsSrcValue->dwType != ADSTYPE_HOLD){
  283. return(0);
  284. }
  285. dwLength = (wcslen(lpAdsSrcValue->Hold.ObjectName) + 1)*sizeof(WCHAR);
  286. dwSize += dwLength;
  287. return(dwSize);
  288. }
  289. DWORD
  290. AdsTypeEmailSize(
  291. PADSVALUE lpAdsSrcValue
  292. )
  293. {
  294. DWORD dwSize = 0;
  295. DWORD dwLength = 0;
  296. if(lpAdsSrcValue->dwType != ADSTYPE_EMAIL){
  297. return(0);
  298. }
  299. dwLength = (wcslen(lpAdsSrcValue->Email.Address) + 1)*sizeof(WCHAR);
  300. dwSize += dwLength;
  301. return(dwSize);
  302. }
  303. DWORD
  304. AdsTypeNetAddressSize(
  305. PADSVALUE lpAdsSrcValue
  306. )
  307. {
  308. DWORD dwSize = 0;
  309. DWORD dwNumBytes = 0;
  310. if(lpAdsSrcValue->dwType != ADSTYPE_NETADDRESS){
  311. return(0);
  312. }
  313. if (lpAdsSrcValue->pNetAddress == NULL) {
  314. return(0);
  315. }
  316. dwSize += sizeof(ADS_NETADDRESS);
  317. dwNumBytes = lpAdsSrcValue->pNetAddress->AddressLength;
  318. dwSize += dwNumBytes;
  319. return(dwSize);
  320. }
  321. DWORD
  322. AdsTypeFaxNumberSize(
  323. PADSVALUE lpAdsSrcValue
  324. )
  325. {
  326. DWORD dwSize = 0;
  327. DWORD dwNumBytes = 0;
  328. DWORD dwLength = 0;
  329. if(lpAdsSrcValue->dwType != ADSTYPE_FAXNUMBER){
  330. return(0);
  331. }
  332. if (lpAdsSrcValue->pFaxNumber == NULL) {
  333. return(0);
  334. }
  335. dwSize += sizeof(ADS_FAXNUMBER);
  336. dwLength = (wcslen(lpAdsSrcValue->pFaxNumber->TelephoneNumber) + 1)*sizeof(WCHAR);
  337. dwSize += dwLength;
  338. dwNumBytes = lpAdsSrcValue->pFaxNumber->NumberOfBits;
  339. dwSize += dwNumBytes;
  340. return(dwSize);
  341. }
  342. DWORD
  343. AdsTypeReplicaPointerSize(
  344. PADSVALUE lpAdsSrcValue
  345. )
  346. {
  347. DWORD dwSize = 0;
  348. DWORD dwNumBytes = 0;
  349. DWORD dwLength = 0;
  350. if(lpAdsSrcValue->dwType != ADSTYPE_REPLICAPOINTER){
  351. return(0);
  352. }
  353. if (lpAdsSrcValue->pReplicaPointer == NULL) {
  354. return(0);
  355. }
  356. dwSize += sizeof(ADS_REPLICAPOINTER);
  357. dwLength = (wcslen(lpAdsSrcValue->pReplicaPointer->ServerName) + 1)*sizeof(WCHAR);
  358. dwSize += dwLength;
  359. dwSize += sizeof(ADS_NETADDRESS);
  360. dwNumBytes = lpAdsSrcValue->pReplicaPointer->ReplicaAddressHints->AddressLength;
  361. dwSize += dwNumBytes;
  362. return(dwSize);
  363. }
  364. DWORD
  365. AdsTypeSize(
  366. PADSVALUE lpAdsSrcValue
  367. )
  368. {
  369. DWORD dwSize = 0;
  370. switch (lpAdsSrcValue->dwType){
  371. case ADSTYPE_DN_STRING:
  372. dwSize = AdsTypeDNStringSize(
  373. lpAdsSrcValue
  374. );
  375. break;
  376. case ADSTYPE_CASE_EXACT_STRING:
  377. dwSize = AdsTypeCaseExactStringSize(
  378. lpAdsSrcValue
  379. );
  380. break;
  381. case ADSTYPE_CASE_IGNORE_STRING:
  382. dwSize = AdsTypeCaseIgnoreStringSize(
  383. lpAdsSrcValue
  384. );
  385. break;
  386. case ADSTYPE_PRINTABLE_STRING:
  387. dwSize = AdsTypePrintableStringSize(
  388. lpAdsSrcValue
  389. );
  390. break;
  391. case ADSTYPE_NUMERIC_STRING:
  392. dwSize = AdsTypeNumericStringSize(
  393. lpAdsSrcValue
  394. );
  395. break;
  396. case ADSTYPE_BOOLEAN:
  397. dwSize = AdsTypeBooleanSize(
  398. lpAdsSrcValue
  399. );
  400. break;
  401. case ADSTYPE_INTEGER:
  402. dwSize = AdsTypeIntegerSize(
  403. lpAdsSrcValue
  404. );
  405. break;
  406. case ADSTYPE_OCTET_STRING:
  407. dwSize = AdsTypeOctetStringSize(
  408. lpAdsSrcValue
  409. );
  410. break;
  411. case ADSTYPE_UTC_TIME:
  412. dwSize = AdsTypeTimeSize(
  413. lpAdsSrcValue
  414. );
  415. break;
  416. case ADSTYPE_OBJECT_CLASS:
  417. dwSize = AdsTypeObjectClassSize(
  418. lpAdsSrcValue
  419. );
  420. break;
  421. case ADSTYPE_CASEIGNORE_LIST:
  422. dwSize = AdsTypeCaseIgnoreListSize(
  423. lpAdsSrcValue
  424. );
  425. break;
  426. case ADSTYPE_FAXNUMBER:
  427. dwSize = AdsTypeFaxNumberSize(
  428. lpAdsSrcValue
  429. );
  430. break;
  431. case ADSTYPE_NETADDRESS:
  432. dwSize = AdsTypeNetAddressSize(
  433. lpAdsSrcValue
  434. );
  435. break;
  436. case ADSTYPE_OCTET_LIST:
  437. dwSize = AdsTypeOctetListSize(
  438. lpAdsSrcValue
  439. );
  440. break;
  441. case ADSTYPE_EMAIL:
  442. dwSize = AdsTypeEmailSize(
  443. lpAdsSrcValue
  444. );
  445. break;
  446. case ADSTYPE_PATH:
  447. dwSize = AdsTypePathSize(
  448. lpAdsSrcValue
  449. );
  450. break;
  451. case ADSTYPE_REPLICAPOINTER:
  452. dwSize = AdsTypeReplicaPointerSize(
  453. lpAdsSrcValue
  454. );
  455. break;
  456. case ADSTYPE_TIMESTAMP:
  457. dwSize = AdsTypeTimestampSize(
  458. lpAdsSrcValue
  459. );
  460. break;
  461. case ADSTYPE_POSTALADDRESS:
  462. dwSize = AdsTypePostalAddressSize(
  463. lpAdsSrcValue
  464. );
  465. break;
  466. case ADSTYPE_BACKLINK:
  467. dwSize = AdsTypeBackLinkSize(
  468. lpAdsSrcValue
  469. );
  470. break;
  471. case ADSTYPE_TYPEDNAME:
  472. dwSize = AdsTypeTypedNameSize(
  473. lpAdsSrcValue
  474. );
  475. break;
  476. case ADSTYPE_HOLD:
  477. dwSize = AdsTypeHoldSize(
  478. lpAdsSrcValue
  479. );
  480. default:
  481. break;
  482. }
  483. return(dwSize);
  484. }
  485.