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.

455 lines
8.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ccache.cxx
  7. //
  8. // Contents: Class Cache functionality for the NwCompat Provider
  9. //
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "nwcompat.hxx"
  13. HRESULT
  14. SetLPTSTRPropertyInCache(
  15. CPropertyCache *pPropertyCache,
  16. LPTSTR pszProperty,
  17. LPTSTR pszValue,
  18. BOOL fExplicit
  19. )
  20. {
  21. HRESULT hr;
  22. if(!pPropertyCache){
  23. RRETURN(E_POINTER);
  24. }
  25. hr = pPropertyCache->unmarshallproperty(
  26. pszProperty,
  27. (LPBYTE)pszValue,
  28. 1,
  29. NT_SYNTAX_ID_LPTSTR,
  30. fExplicit
  31. );
  32. BAIL_ON_FAILURE(hr);
  33. error:
  34. RRETURN(hr);
  35. }
  36. HRESULT
  37. SetDWORDPropertyInCache(
  38. CPropertyCache *pPropertyCache,
  39. LPTSTR pszProperty,
  40. DWORD dwValue,
  41. BOOL fExplicit
  42. )
  43. {
  44. HRESULT hr;
  45. if(!pPropertyCache){
  46. RRETURN(E_POINTER);
  47. }
  48. hr = pPropertyCache->unmarshallproperty(
  49. pszProperty,
  50. (LPBYTE)&dwValue,
  51. 1,
  52. NT_SYNTAX_ID_DWORD,
  53. fExplicit
  54. );
  55. BAIL_ON_FAILURE(hr);
  56. error:
  57. RRETURN(hr);
  58. }
  59. HRESULT
  60. SetDATEPropertyInCache(
  61. CPropertyCache *pPropertyCache,
  62. LPTSTR pszProperty,
  63. DWORD dwValue,
  64. BOOL fExplicit
  65. )
  66. {
  67. HRESULT hr;
  68. if(!pPropertyCache){
  69. RRETURN(E_POINTER);
  70. }
  71. hr = pPropertyCache->unmarshallproperty(
  72. pszProperty,
  73. (LPBYTE)&dwValue,
  74. 1,
  75. NT_SYNTAX_ID_DATE,
  76. fExplicit
  77. );
  78. BAIL_ON_FAILURE(hr);
  79. error:
  80. RRETURN(hr);
  81. }
  82. HRESULT
  83. SetBOOLPropertyInCache(
  84. CPropertyCache *pPropertyCache,
  85. LPTSTR pszProperty,
  86. BOOL fValue,
  87. BOOL fExplicit
  88. )
  89. {
  90. HRESULT hr;
  91. if(!pPropertyCache){
  92. RRETURN(E_POINTER);
  93. }
  94. hr = pPropertyCache->unmarshallproperty(
  95. pszProperty,
  96. (LPBYTE)&fValue,
  97. 1,
  98. NT_SYNTAX_ID_BOOL,
  99. fExplicit
  100. );
  101. BAIL_ON_FAILURE(hr);
  102. error:
  103. RRETURN(hr);
  104. }
  105. HRESULT
  106. SetOctetPropertyInCache(
  107. CPropertyCache *pPropertyCache,
  108. LPTSTR pszProperty,
  109. BYTE *pByte,
  110. DWORD dwLength,
  111. BOOL fExplicit
  112. )
  113. {
  114. HRESULT hr;
  115. OctetString octString;
  116. if(!pPropertyCache){
  117. RRETURN(E_POINTER);
  118. }
  119. octString.pByte = pByte;
  120. octString.dwSize = dwLength;
  121. hr = pPropertyCache->unmarshallproperty(
  122. pszProperty,
  123. (LPBYTE)&octString,
  124. 1,
  125. NT_SYNTAX_ID_OCTETSTRING,
  126. fExplicit
  127. );
  128. BAIL_ON_FAILURE(hr);
  129. error:
  130. RRETURN(hr);
  131. }
  132. HRESULT
  133. SetSYSTEMTIMEPropertyInCache(
  134. CPropertyCache *pPropertyCache,
  135. LPTSTR pszProperty,
  136. SYSTEMTIME stValue,
  137. BOOL fExplicit
  138. )
  139. {
  140. HRESULT hr;
  141. if(!pPropertyCache){
  142. RRETURN(E_POINTER);
  143. }
  144. hr = pPropertyCache->unmarshallproperty(
  145. pszProperty,
  146. (LPBYTE)&stValue,
  147. 1,
  148. NT_SYNTAX_ID_SYSTEMTIME,
  149. fExplicit
  150. );
  151. BAIL_ON_FAILURE(hr);
  152. error:
  153. RRETURN(hr);
  154. }
  155. HRESULT
  156. SetDelimitedStringPropertyInCache(
  157. CPropertyCache *pPropertyCache,
  158. LPTSTR pszProperty,
  159. LPTSTR pszValue,
  160. BOOL fExplicit
  161. )
  162. {
  163. HRESULT hr;
  164. if(!pPropertyCache){
  165. RRETURN(E_POINTER);
  166. }
  167. hr = pPropertyCache->unmarshallproperty(
  168. pszProperty,
  169. (LPBYTE)pszValue,
  170. 1,
  171. NT_SYNTAX_ID_DelimitedString,
  172. fExplicit
  173. );
  174. BAIL_ON_FAILURE(hr);
  175. error:
  176. RRETURN(hr);
  177. }
  178. HRESULT
  179. SetNulledStringPropertyInCache(
  180. CPropertyCache *pPropertyCache,
  181. LPTSTR pszProperty,
  182. LPTSTR pszValue,
  183. BOOL fExplicit
  184. )
  185. {
  186. HRESULT hr;
  187. if(!pPropertyCache){
  188. RRETURN(E_POINTER);
  189. }
  190. hr = pPropertyCache->unmarshallproperty(
  191. pszProperty,
  192. (LPBYTE)pszValue,
  193. 1,
  194. NT_SYNTAX_ID_NulledString,
  195. fExplicit
  196. );
  197. BAIL_ON_FAILURE(hr);
  198. error:
  199. RRETURN(hr);
  200. }
  201. HRESULT
  202. GetPropertyFromCache(
  203. CPropertyCache * pPropertyCache,
  204. LPTSTR pszProperty,
  205. LPBYTE pValue
  206. )
  207. {
  208. HRESULT hr = S_OK;
  209. DWORD dwSyntaxId = 0;
  210. DWORD dwNumValues = 0;
  211. PNTOBJECT pNTObject = NULL;
  212. hr = pPropertyCache->marshallgetproperty(
  213. pszProperty,
  214. &dwSyntaxId,
  215. &dwNumValues,
  216. &pNTObject
  217. );
  218. BAIL_ON_FAILURE(hr);
  219. hr = MarshallNTSynIdToNT(
  220. dwSyntaxId,
  221. pNTObject,
  222. dwNumValues,
  223. pValue
  224. );
  225. BAIL_ON_FAILURE(hr);
  226. error:
  227. if (pNTObject)
  228. NTTypeFreeNTObjects(pNTObject, dwNumValues);
  229. RRETURN (hr);
  230. }
  231. HRESULT
  232. GetLPTSTRPropertyFromCache(
  233. CPropertyCache * pPropertyCache,
  234. LPTSTR pszProperty,
  235. LPTSTR * ppszValue
  236. )
  237. {
  238. HRESULT hr;
  239. hr = GetPropertyFromCache(pPropertyCache,
  240. pszProperty,
  241. (LPBYTE)ppszValue);
  242. RRETURN(hr);
  243. }
  244. HRESULT
  245. GetDelimitedStringPropertyFromCache(
  246. CPropertyCache * pPropertyCache,
  247. LPTSTR pszProperty,
  248. LPTSTR * ppszValue
  249. )
  250. {
  251. HRESULT hr;
  252. hr = GetPropertyFromCache(pPropertyCache,
  253. pszProperty,
  254. (LPBYTE)ppszValue);
  255. RRETURN (hr);
  256. }
  257. HRESULT
  258. GetNulledStringPropertyFromCache(
  259. CPropertyCache * pPropertyCache,
  260. LPTSTR pszProperty,
  261. LPTSTR * ppszValue
  262. )
  263. {
  264. HRESULT hr;
  265. hr = GetPropertyFromCache(pPropertyCache,
  266. pszProperty,
  267. (LPBYTE)ppszValue);
  268. RRETURN(hr);
  269. }
  270. HRESULT
  271. GetBOOLPropertyFromCache(
  272. CPropertyCache * pPropertyCache,
  273. LPTSTR pszProperty,
  274. PBOOL pBool
  275. )
  276. {
  277. HRESULT hr;
  278. hr = GetPropertyFromCache(pPropertyCache,
  279. pszProperty,
  280. (LPBYTE)pBool);
  281. RRETURN(hr);
  282. }
  283. HRESULT
  284. GetOctetPropertyFromCache(
  285. CPropertyCache * pPropertyCache,
  286. LPTSTR pszProperty,
  287. OctetString *pOctet)
  288. {
  289. HRESULT hr;
  290. hr = GetPropertyFromCache(pPropertyCache,
  291. pszProperty,
  292. (LPBYTE)pOctet);
  293. RRETURN(hr);
  294. }
  295. HRESULT
  296. GetDWORDPropertyFromCache(
  297. CPropertyCache * pPropertyCache,
  298. LPTSTR pszProperty,
  299. LPDWORD pdwDWORD
  300. )
  301. {
  302. HRESULT hr;
  303. hr = GetPropertyFromCache(pPropertyCache,
  304. pszProperty,
  305. (LPBYTE)pdwDWORD);
  306. RRETURN(hr);
  307. }
  308. HRESULT
  309. GetDATEPropertyFromCache(
  310. CPropertyCache * pPropertyCache,
  311. LPTSTR pszProperty,
  312. PDWORD pdwDate
  313. )
  314. {
  315. HRESULT hr;
  316. hr = GetPropertyFromCache(pPropertyCache,
  317. pszProperty,
  318. (LPBYTE)pdwDate);
  319. RRETURN(hr);
  320. }
  321. HRESULT
  322. GetNw312DATEPropertyFromCache(
  323. CPropertyCache * pPropertyCache,
  324. LPTSTR pszProperty,
  325. BYTE byDateTime[]
  326. )
  327. {
  328. HRESULT hr = S_OK;
  329. DWORD dwSyntaxId = 0;
  330. DWORD dwNumValues = 0;
  331. PNTOBJECT pNTObject = NULL;
  332. hr = pPropertyCache->marshallgetproperty(
  333. pszProperty,
  334. &dwSyntaxId,
  335. &dwNumValues,
  336. &pNTObject
  337. );
  338. BAIL_ON_FAILURE(hr);
  339. if(SUCCEEDED(hr)){
  340. hr = MarshallNTSynIdToNT(
  341. dwSyntaxId,
  342. pNTObject,
  343. dwNumValues,
  344. (LPBYTE)byDateTime
  345. );
  346. }
  347. error:
  348. if (pNTObject)
  349. NTTypeFreeNTObjects(pNTObject, dwNumValues);
  350. RRETURN (hr);
  351. }
  352. HRESULT
  353. SetNw312DATEPropertyInCache(
  354. CPropertyCache *pPropertyCache,
  355. LPTSTR pszProperty,
  356. BYTE byDateTime[],
  357. BOOL fExplicit
  358. )
  359. {
  360. HRESULT hr;
  361. if(!pPropertyCache){
  362. RRETURN(E_POINTER);
  363. }
  364. hr = pPropertyCache->unmarshallproperty(
  365. pszProperty,
  366. (LPBYTE)byDateTime,
  367. 1,
  368. NT_SYNTAX_ID_NW312DATE,
  369. fExplicit
  370. );
  371. BAIL_ON_FAILURE(hr);
  372. error:
  373. RRETURN(hr);
  374. }