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.

379 lines
7.4 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. // Issues: Check null ptrs for AllocADsMem and AllocADsStr
  16. //
  17. //----------------------------------------------------------------------------
  18. #include "nds.hxx"
  19. LPBYTE
  20. AdsTypeCopyDNString(
  21. PADSVALUE lpAdsSrcValue,
  22. PADSVALUE lpAdsDestValue,
  23. LPBYTE lpBuffer
  24. )
  25. {
  26. DWORD dwLength = 0;
  27. if(lpAdsSrcValue->dwType != ADSTYPE_DN_STRING){
  28. return(lpBuffer);
  29. }
  30. lpAdsDestValue->dwType = ADSTYPE_DN_STRING;
  31. lpAdsDestValue->DNString = (LPWSTR)lpBuffer;
  32. wcscpy((LPWSTR)lpBuffer, lpAdsSrcValue->DNString);
  33. dwLength = (wcslen(lpAdsSrcValue->DNString) + 1)*sizeof(WCHAR);
  34. lpBuffer += dwLength;
  35. return(lpBuffer);
  36. }
  37. LPBYTE
  38. AdsTypeCopyCaseExactString(
  39. PADSVALUE lpAdsSrcValue,
  40. PADSVALUE lpAdsDestValue,
  41. LPBYTE lpBuffer
  42. )
  43. {
  44. DWORD dwLength = 0;
  45. if(lpAdsSrcValue->dwType != ADSTYPE_CASE_EXACT_STRING){
  46. return(lpBuffer);
  47. }
  48. lpAdsDestValue->dwType = ADSTYPE_CASE_EXACT_STRING;
  49. lpAdsDestValue->CaseExactString = (LPWSTR)lpBuffer;
  50. wcscpy((LPWSTR)lpBuffer, lpAdsSrcValue->CaseExactString);
  51. dwLength = (wcslen(lpAdsSrcValue->CaseExactString) + 1)*sizeof(WCHAR);
  52. lpBuffer += dwLength;
  53. return(lpBuffer);
  54. }
  55. LPBYTE
  56. AdsTypeCopyCaseIgnoreString(
  57. PADSVALUE lpAdsSrcValue,
  58. PADSVALUE lpAdsDestValue,
  59. LPBYTE lpBuffer
  60. )
  61. {
  62. DWORD dwLength = 0;
  63. if(lpAdsSrcValue->dwType != ADSTYPE_CASE_IGNORE_STRING){
  64. return(lpBuffer);
  65. }
  66. lpAdsDestValue->dwType = ADSTYPE_CASE_IGNORE_STRING;
  67. lpAdsDestValue->CaseIgnoreString = (LPWSTR)lpBuffer;
  68. wcscpy((LPWSTR)lpBuffer, lpAdsSrcValue->CaseIgnoreString);
  69. dwLength = (wcslen(lpAdsSrcValue->CaseIgnoreString) + 1)*sizeof(WCHAR);
  70. lpBuffer += dwLength;
  71. return(lpBuffer);
  72. }
  73. LPBYTE
  74. AdsTypeCopyPrintableString(
  75. PADSVALUE lpAdsSrcValue,
  76. PADSVALUE lpAdsDestValue,
  77. LPBYTE lpBuffer
  78. )
  79. {
  80. DWORD dwLength = 0;
  81. if(lpAdsSrcValue->dwType != ADSTYPE_PRINTABLE_STRING){
  82. return(lpBuffer);
  83. }
  84. lpAdsDestValue->dwType = ADSTYPE_PRINTABLE_STRING;
  85. lpAdsDestValue->PrintableString = (LPWSTR)lpBuffer;
  86. wcscpy((LPWSTR)lpBuffer, lpAdsSrcValue->PrintableString);
  87. dwLength = (wcslen(lpAdsSrcValue->PrintableString) + 1)*sizeof(WCHAR);
  88. lpBuffer += dwLength;
  89. return(lpBuffer);
  90. }
  91. LPBYTE
  92. AdsTypeCopyNumericString(
  93. PADSVALUE lpAdsSrcValue,
  94. PADSVALUE lpAdsDestValue,
  95. LPBYTE lpBuffer
  96. )
  97. {
  98. DWORD dwLength = 0;
  99. if(lpAdsSrcValue->dwType != ADSTYPE_NUMERIC_STRING){
  100. return(lpBuffer);
  101. }
  102. lpAdsDestValue->dwType = ADSTYPE_NUMERIC_STRING;
  103. lpAdsDestValue->NumericString = (LPWSTR)lpBuffer;
  104. wcscpy((LPWSTR)lpBuffer, lpAdsSrcValue->NumericString);
  105. dwLength = (wcslen(lpAdsSrcValue->NumericString) + 1)*sizeof(WCHAR);
  106. lpBuffer += dwLength;
  107. return(lpBuffer);
  108. }
  109. LPBYTE
  110. AdsTypeCopyBoolean(
  111. PADSVALUE lpAdsSrcValue,
  112. PADSVALUE lpAdsDestValue,
  113. LPBYTE lpBuffer
  114. )
  115. {
  116. if(lpAdsSrcValue->dwType != ADSTYPE_BOOLEAN){
  117. return(lpBuffer);
  118. }
  119. lpAdsDestValue->dwType = ADSTYPE_BOOLEAN;
  120. lpAdsDestValue->Boolean =
  121. lpAdsSrcValue->Boolean;
  122. return(lpBuffer);
  123. }
  124. LPBYTE
  125. AdsTypeCopyInteger(
  126. PADSVALUE lpAdsSrcValue,
  127. PADSVALUE lpAdsDestValue,
  128. LPBYTE lpBuffer
  129. )
  130. {
  131. if(lpAdsSrcValue->dwType != ADSTYPE_INTEGER){
  132. return(lpBuffer);
  133. }
  134. lpAdsDestValue->dwType = ADSTYPE_INTEGER;
  135. lpAdsDestValue->Integer =
  136. lpAdsSrcValue->Integer;
  137. return(lpBuffer);
  138. }
  139. LPBYTE
  140. AdsTypeCopyOctetString(
  141. PADSVALUE lpAdsSrcValue,
  142. PADSVALUE lpAdsDestValue,
  143. LPBYTE lpBuffer
  144. )
  145. {
  146. LPBYTE lpByteStream = NULL;
  147. DWORD dwNumBytes = 0;
  148. if(lpAdsSrcValue->dwType != ADSTYPE_OCTET_STRING){
  149. return(lpBuffer);
  150. }
  151. lpAdsDestValue->dwType = ADSTYPE_OCTET_STRING;
  152. dwNumBytes = lpAdsSrcValue->OctetString.dwLength;
  153. memcpy(
  154. lpBuffer,
  155. lpAdsSrcValue->OctetString.lpValue,
  156. dwNumBytes
  157. );
  158. lpAdsDestValue->OctetString.dwLength = dwNumBytes;
  159. lpAdsDestValue->OctetString.lpValue = lpBuffer;
  160. lpBuffer += dwNumBytes;
  161. return(lpBuffer);
  162. }
  163. LPBYTE
  164. AdsTypeCopyTime(
  165. PADSVALUE lpAdsSrcValue,
  166. PADSVALUE lpAdsDestValue,
  167. LPBYTE lpBuffer
  168. )
  169. {
  170. if(lpAdsSrcValue->dwType != ADSTYPE_UTC_TIME){
  171. return(lpBuffer);
  172. }
  173. lpAdsDestValue->dwType = ADSTYPE_UTC_TIME;
  174. lpAdsDestValue->UTCTime =
  175. lpAdsSrcValue->UTCTime;
  176. return(lpBuffer);
  177. }
  178. LPBYTE
  179. AdsTypeCopyObjectClass(
  180. PADSVALUE lpAdsSrcValue,
  181. PADSVALUE lpAdsDestValue,
  182. LPBYTE lpBuffer
  183. )
  184. {
  185. DWORD dwLength = 0;
  186. if(lpAdsSrcValue->dwType != ADSTYPE_OBJECT_CLASS){
  187. return(lpBuffer);
  188. }
  189. lpAdsDestValue->dwType = ADSTYPE_OBJECT_CLASS;
  190. lpAdsDestValue->ClassName = (LPWSTR)lpBuffer;
  191. wcscpy((LPWSTR)lpBuffer, lpAdsSrcValue->ClassName);
  192. dwLength = (wcslen(lpAdsSrcValue->ClassName) + 1)*sizeof(WCHAR);
  193. lpBuffer += dwLength;
  194. return(lpBuffer);
  195. }
  196. LPBYTE
  197. AdsTypeCopy(
  198. PADSVALUE lpAdsSrcValue,
  199. PADSVALUE lpAdsDestValue,
  200. LPBYTE lpBuffer
  201. )
  202. {
  203. switch (lpAdsSrcValue->dwType){
  204. case ADSTYPE_DN_STRING:
  205. lpBuffer = AdsTypeCopyDNString(
  206. lpAdsSrcValue,
  207. lpAdsDestValue,
  208. lpBuffer
  209. );
  210. break;
  211. case ADSTYPE_CASE_EXACT_STRING:
  212. lpBuffer = AdsTypeCopyCaseExactString(
  213. lpAdsSrcValue,
  214. lpAdsDestValue,
  215. lpBuffer
  216. );
  217. break;
  218. case ADSTYPE_CASE_IGNORE_STRING:
  219. lpBuffer = AdsTypeCopyCaseIgnoreString(
  220. lpAdsSrcValue,
  221. lpAdsDestValue,
  222. lpBuffer
  223. );
  224. break;
  225. case ADSTYPE_PRINTABLE_STRING:
  226. lpBuffer = AdsTypeCopyPrintableString(
  227. lpAdsSrcValue,
  228. lpAdsDestValue,
  229. lpBuffer
  230. );
  231. break;
  232. case ADSTYPE_NUMERIC_STRING:
  233. lpBuffer = AdsTypeCopyNumericString(
  234. lpAdsSrcValue,
  235. lpAdsDestValue,
  236. lpBuffer
  237. );
  238. break;
  239. case ADSTYPE_BOOLEAN:
  240. lpBuffer = AdsTypeCopyBoolean(
  241. lpAdsSrcValue,
  242. lpAdsDestValue,
  243. lpBuffer
  244. );
  245. break;
  246. case ADSTYPE_INTEGER:
  247. lpBuffer = AdsTypeCopyInteger(
  248. lpAdsSrcValue,
  249. lpAdsDestValue,
  250. lpBuffer
  251. );
  252. break;
  253. case ADSTYPE_OCTET_STRING:
  254. lpBuffer = AdsTypeCopyOctetString(
  255. lpAdsSrcValue,
  256. lpAdsDestValue,
  257. lpBuffer
  258. );
  259. break;
  260. case ADSTYPE_UTC_TIME:
  261. lpBuffer = AdsTypeCopyTime(
  262. lpAdsSrcValue,
  263. lpAdsDestValue,
  264. lpBuffer
  265. );
  266. break;
  267. case ADSTYPE_OBJECT_CLASS:
  268. lpBuffer = AdsTypeCopyObjectClass(
  269. lpAdsSrcValue,
  270. lpAdsDestValue,
  271. lpBuffer
  272. );
  273. break;
  274. default:
  275. break;
  276. }
  277. return(lpBuffer);
  278. }