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.

266 lines
4.3 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. DWORD
  20. AdsTypeDNStringSize(
  21. PADSVALUE lpAdsSrcValue
  22. )
  23. {
  24. DWORD dwSize = 0;
  25. if(lpAdsSrcValue->dwType != ADSTYPE_DN_STRING){
  26. return(0);
  27. }
  28. dwSize = (wcslen(lpAdsSrcValue->DNString) + 1)*sizeof(WCHAR);
  29. return(dwSize);
  30. }
  31. DWORD
  32. AdsTypeCaseExactStringSize(
  33. PADSVALUE lpAdsSrcValue
  34. )
  35. {
  36. DWORD dwSize = 0;
  37. if(lpAdsSrcValue->dwType != ADSTYPE_CASE_EXACT_STRING){
  38. return(0);
  39. }
  40. dwSize = (wcslen(lpAdsSrcValue->CaseExactString) + 1) *sizeof(WCHAR);
  41. return(dwSize);
  42. }
  43. DWORD
  44. AdsTypeCaseIgnoreStringSize(
  45. PADSVALUE lpAdsSrcValue
  46. )
  47. {
  48. DWORD dwSize = 0;
  49. if(lpAdsSrcValue->dwType != ADSTYPE_CASE_IGNORE_STRING){
  50. return(0);
  51. }
  52. dwSize = (wcslen(lpAdsSrcValue->CaseIgnoreString) + 1) *sizeof(WCHAR);
  53. return(dwSize);
  54. }
  55. DWORD
  56. AdsTypePrintableStringSize(
  57. PADSVALUE lpAdsSrcValue
  58. )
  59. {
  60. DWORD dwSize = 0;
  61. if(lpAdsSrcValue->dwType != ADSTYPE_PRINTABLE_STRING){
  62. return(0);
  63. }
  64. dwSize = (wcslen(lpAdsSrcValue->PrintableString) + 1) *sizeof(WCHAR);
  65. return(dwSize);
  66. }
  67. DWORD
  68. AdsTypeNumericStringSize(
  69. PADSVALUE lpAdsSrcValue
  70. )
  71. {
  72. DWORD dwSize = 0;
  73. if(lpAdsSrcValue->dwType != ADSTYPE_NUMERIC_STRING){
  74. return(0);
  75. }
  76. dwSize = (wcslen(lpAdsSrcValue->NumericString) + 1)* sizeof(WCHAR);
  77. return(dwSize);
  78. }
  79. DWORD
  80. AdsTypeBooleanSize(
  81. PADSVALUE lpAdsSrcValue
  82. )
  83. {
  84. if(lpAdsSrcValue->dwType != ADSTYPE_BOOLEAN){
  85. return(0);
  86. }
  87. return(0);
  88. }
  89. DWORD
  90. AdsTypeIntegerSize(
  91. PADSVALUE lpAdsSrcValue
  92. )
  93. {
  94. DWORD dwSize = 0;
  95. if(lpAdsSrcValue->dwType != ADSTYPE_INTEGER){
  96. return(0);
  97. }
  98. return(0);
  99. }
  100. DWORD
  101. AdsTypeOctetStringSize(
  102. PADSVALUE lpAdsSrcValue
  103. )
  104. {
  105. DWORD dwNumBytes = 0;
  106. if(lpAdsSrcValue->dwType != ADSTYPE_OCTET_STRING){
  107. return(0);
  108. }
  109. dwNumBytes = lpAdsSrcValue->OctetString.dwLength;
  110. return(dwNumBytes);
  111. }
  112. DWORD
  113. AdsTypeTimeSize(
  114. PADSVALUE lpAdsSrcValue
  115. )
  116. {
  117. if(lpAdsSrcValue->dwType != ADSTYPE_UTC_TIME){
  118. return(0);
  119. }
  120. return(0);
  121. }
  122. DWORD
  123. AdsTypeObjectClassSize(
  124. PADSVALUE lpAdsSrcValue
  125. )
  126. {
  127. DWORD dwSize = 0;
  128. if(lpAdsSrcValue->dwType != ADSTYPE_OBJECT_CLASS){
  129. return(0);
  130. }
  131. dwSize = (wcslen(lpAdsSrcValue->ClassName) + 1)*sizeof(WCHAR);
  132. return(dwSize);
  133. }
  134. DWORD
  135. AdsTypeSize(
  136. PADSVALUE lpAdsSrcValue
  137. )
  138. {
  139. DWORD dwSize = 0;
  140. switch (lpAdsSrcValue->dwType){
  141. case ADSTYPE_DN_STRING:
  142. dwSize = AdsTypeDNStringSize(
  143. lpAdsSrcValue
  144. );
  145. break;
  146. case ADSTYPE_CASE_EXACT_STRING:
  147. dwSize = AdsTypeCaseExactStringSize(
  148. lpAdsSrcValue
  149. );
  150. break;
  151. case ADSTYPE_CASE_IGNORE_STRING:
  152. dwSize = AdsTypeCaseIgnoreStringSize(
  153. lpAdsSrcValue
  154. );
  155. break;
  156. case ADSTYPE_PRINTABLE_STRING:
  157. dwSize = AdsTypePrintableStringSize(
  158. lpAdsSrcValue
  159. );
  160. break;
  161. case ADSTYPE_NUMERIC_STRING:
  162. dwSize = AdsTypeNumericStringSize(
  163. lpAdsSrcValue
  164. );
  165. break;
  166. case ADSTYPE_BOOLEAN:
  167. dwSize = AdsTypeBooleanSize(
  168. lpAdsSrcValue
  169. );
  170. break;
  171. case ADSTYPE_INTEGER:
  172. dwSize = AdsTypeIntegerSize(
  173. lpAdsSrcValue
  174. );
  175. break;
  176. case ADSTYPE_OCTET_STRING:
  177. dwSize = AdsTypeOctetStringSize(
  178. lpAdsSrcValue
  179. );
  180. break;
  181. case ADSTYPE_UTC_TIME:
  182. dwSize = AdsTypeTimeSize(
  183. lpAdsSrcValue
  184. );
  185. break;
  186. case ADSTYPE_OBJECT_CLASS:
  187. dwSize = AdsTypeObjectClassSize(
  188. lpAdsSrcValue
  189. );
  190. break;
  191. default:
  192. break;
  193. }
  194. return(dwSize);
  195. }
  196.