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.

390 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: msffunc.hxx
  7. //
  8. // Contents: Multistream inline functions
  9. //
  10. // Classes: None.
  11. //
  12. // History: 14-Seo-92 PhilipLa Created.
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef __MSFFUNC_HXX__
  16. #define __MSFFUNC_HXX__
  17. #include <msf.hxx>
  18. #include <dir.hxx>
  19. #include <dirfunc.hxx>
  20. #if !defined(MULTIHEAP) // moved to msf.cxx
  21. //+--------------------------------------------------------------
  22. //
  23. // Member: CMStream::GetMalloc, public
  24. //
  25. // Synopsis: Returns the allocator associated with this multistream
  26. //
  27. // History: 05-May-93 AlexT Created
  28. //
  29. //---------------------------------------------------------------
  30. inline IMalloc * CMStream::GetMalloc(VOID) const
  31. {
  32. return (IMalloc *)_pMalloc;
  33. }
  34. #endif
  35. //+-------------------------------------------------------------------------
  36. //
  37. // Member: CMStream::RenameEntry, public
  38. //
  39. // Synposis: Rename an entry.
  40. //
  41. // Arguments: [sidParent] - Parent SID
  42. // [pdfn] - Old name
  43. // [pdfnNew] -- New name
  44. //
  45. // Returns: S_OK otherwise
  46. //
  47. // Algorithm: Call through to CDirectory::RenameEntry
  48. //
  49. // History: 27-Aug-91 PhilipLa Created.
  50. // 07-Jan-92 PhilipLa Converted to use handle.
  51. // 14-Sep-92 PhilipLa inlined.
  52. //
  53. // Notes:
  54. //
  55. //---------------------------------------------------------------------------
  56. inline SCODE CMStream::RenameEntry(
  57. SID const sidParent,
  58. CDfName const *pdfn,
  59. CDfName const *pdfnNew)
  60. {
  61. return _dir.RenameEntry(sidParent, pdfn, pdfnNew);
  62. }
  63. //+-------------------------------------------------------------------------
  64. //
  65. // Member: CMStream::IsEntry, public
  66. //
  67. // Synposis: Determine if a given entry is present in a multistream
  68. //
  69. // Arguments: [sidParent] - Parent SID
  70. // [pdfn] -- Name of entry to be located
  71. // [peb] - Entry block to fill in
  72. //
  73. // Returns: S_OK if entry exists.
  74. // STG_E_FILENOTFOUND if it doesn't.
  75. //
  76. // History: 27-Aug-91 PhilipLa Created.
  77. // 07-Jan-92 PhilipLa Converted to use handle
  78. // 14-Sep-92 PhilipLa inlined.
  79. //
  80. //---------------------------------------------------------------------------
  81. inline SCODE CMStream::IsEntry(
  82. SID const sidParent,
  83. CDfName const *pdfn,
  84. SEntryBuffer *peb)
  85. {
  86. return _dir.IsEntry(sidParent, pdfn, peb);
  87. }
  88. //+-------------------------------------------------------------------------
  89. //
  90. // Member: CMStream::CreateEntry, public
  91. //
  92. // Synposis: Allows creation of new entries
  93. //
  94. // Arguments: [sidParent] -- SID of parent entry
  95. // [pdfn] -- Name of new entry
  96. // [mefFlags] -- Flags to be set on new entry
  97. // [psid] -- Location for return SID
  98. //
  99. // Returns: S_OK if call completed OK.
  100. // STG_E_FILEALREADYEXISTS if stream already exists
  101. //
  102. // History: 20-Jul-91 PhilipLa Created.
  103. // 27-Aug-91 PhilipLa Modified to fit new API
  104. // 06-Jan-91 PhilipLa Changed from CreateStream to
  105. // CreateEntry
  106. // 14-Sep-92 PhilipLa inlined.
  107. //
  108. //---------------------------------------------------------------------------
  109. inline SCODE CMStream::CreateEntry(
  110. SID const sidParent,
  111. CDfName const *pdfn,
  112. MSENTRYFLAGS const mefFlags,
  113. SID *psid)
  114. {
  115. return _dir.CreateEntry(sidParent, pdfn, mefFlags, psid);
  116. }
  117. //+-------------------------------------------------------------------------
  118. //
  119. // Method: CMStream::StatEntry
  120. //
  121. // Synopsis: For a given handle, fill in the Multistream specific
  122. // information of a STATSTG.
  123. //
  124. // Arguments: [sid] -- SID that information is requested on.
  125. // [pib] -- Fast iterator buffer to fill in.
  126. // [pstatstg] -- STATSTG to fill in.
  127. //
  128. // Returns: S_OK
  129. //
  130. // History: 25-Mar-92 PhilipLa Created.
  131. // 14-Sep-92 PhilipLa inlined.
  132. //
  133. //--------------------------------------------------------------------------
  134. inline SCODE CMStream::StatEntry(SID const sid,
  135. SIterBuffer *pib,
  136. STATSTGW *pstatstg)
  137. {
  138. return _dir.StatEntry(sid, pib, pstatstg);
  139. }
  140. //+-------------------------------------------------------------------------
  141. //
  142. // Member: CMStream::GetChild, public
  143. //
  144. // Synposis: Return the child SID for a directory entry
  145. //
  146. // Arguments: [sid] - Parent
  147. // [psid] - Child SID return
  148. //
  149. // Returns: Appropriate status code
  150. //
  151. // History: 19-Apr-93 DrewB Created
  152. //
  153. //---------------------------------------------------------------------------
  154. inline SCODE CMStream::GetChild(
  155. SID const sid,
  156. SID *psid)
  157. {
  158. return _dir.GetChild(sid, psid);
  159. }
  160. //+---------------------------------------------------------------------------
  161. //
  162. // Member: CMStream::FindGreaterEntry, public
  163. //
  164. // Synopsis: Returns the next greater entry for the given parent SID
  165. //
  166. // Arguments: [sidParent] - SID of parent storage
  167. // [CDfName *pdfnKey] - Previous key
  168. // [psid] - Result
  169. //
  170. // Returns: Appropriate status code
  171. //
  172. // Modifies: [psid]
  173. //
  174. // History: 16-Apr-93 DrewB Created
  175. //
  176. //----------------------------------------------------------------------------
  177. inline SCODE CMStream::FindGreaterEntry(SID sidParent,
  178. CDfName const *pdfnKey,
  179. SID *psid)
  180. {
  181. return _dir.FindGreaterEntry(sidParent, pdfnKey, psid);
  182. }
  183. //+---------------------------------------------------------------------------
  184. //
  185. // Member: CMStream::GetClass, public
  186. //
  187. // Synopsis: Gets the class ID
  188. //
  189. // Arguments: [pclsid] - Class ID return
  190. //
  191. // Returns: Appropriate status code
  192. //
  193. // Modifies: [pclsid]
  194. //
  195. // History: 11-Nov-92 DrewB Created
  196. //
  197. //----------------------------------------------------------------------------
  198. inline SCODE CMStream::GetClass(SID const sid,
  199. CLSID *pclsid)
  200. {
  201. return _dir.GetClassId(sid, pclsid);
  202. }
  203. //+---------------------------------------------------------------------------
  204. //
  205. // Member: CMStream::SetClass, public
  206. //
  207. // Synopsis: Sets the class ID
  208. //
  209. // Arguments: [clsid] - Class ID
  210. //
  211. // Returns: Appropriate status code
  212. //
  213. // History: 11-Nov-92 DrewB Created
  214. //
  215. //----------------------------------------------------------------------------
  216. inline SCODE CMStream::SetClass(SID const sid,
  217. REFCLSID clsid)
  218. {
  219. return _dir.SetClassId(sid, clsid);
  220. }
  221. //+---------------------------------------------------------------------------
  222. //
  223. // Member: CMStream::GetStateBits, public
  224. //
  225. // Synopsis: Gets state bits
  226. //
  227. // Arguments: [pgrfStateBits] - State bits return
  228. //
  229. // Returns: Appropriate status code
  230. //
  231. // Modifies: [pgrfStateBits]
  232. //
  233. // History: 11-Nov-92 DrewB Created
  234. //
  235. //----------------------------------------------------------------------------
  236. inline SCODE CMStream::GetStateBits(SID const sid,
  237. DWORD *pgrfStateBits)
  238. {
  239. return _dir.GetUserFlags(sid, pgrfStateBits);
  240. }
  241. //+---------------------------------------------------------------------------
  242. //
  243. // Member: CMStream::SetStateBits, public
  244. //
  245. // Synopsis: Sets state bits
  246. //
  247. // Arguments: [grfStateBits] - State bits
  248. //
  249. // Returns: Appropriate status code
  250. //
  251. // History: 11-Nov-92 DrewB Created
  252. //
  253. //----------------------------------------------------------------------------
  254. inline SCODE CMStream::SetStateBits(SID const sid,
  255. DWORD grfStateBits,
  256. DWORD grfMask)
  257. {
  258. return _dir.SetUserFlags(sid, grfStateBits, grfMask);
  259. }
  260. //+-------------------------------------------------------------------------
  261. //
  262. // Method: CMStream::GetEntrySize, public
  263. //
  264. // Synopsis: Return the size of an entry
  265. //
  266. // Arguments: [sid] - SID of entry
  267. // [pcbSize] -- Location for return of size
  268. //
  269. // Returns: S_OK if call completed OK.
  270. //
  271. // Algorithm: Ask directory for size
  272. //
  273. // History: 07-Jan-92 PhilipLa Created.
  274. // 25-Aug-92 DrewB Created from GetStream
  275. // 14-Sep-92 PhilipLa inlined.
  276. //
  277. //--------------------------------------------------------------------------
  278. inline SCODE CMStream::GetEntrySize(SID const sid,
  279. #ifdef LARGE_STREAMS
  280. ULONGLONG *pcbSize)
  281. #else
  282. ULONG *pcbSize)
  283. #endif
  284. {
  285. return _dir.GetSize(sid, pcbSize);
  286. }
  287. //+-------------------------------------------------------------------------
  288. //
  289. // Member: CMStream::DestroyEntry
  290. //
  291. // Synposis: Delete a directory entry from a multi-stream.
  292. //
  293. // Effects: Modifies directory.
  294. //
  295. // Arguments: [sidParent] - Parent SID
  296. // [pdfn] - Name of entry
  297. //
  298. // Returns: S_OK if operation completed successfully.
  299. //
  300. // Algorithm: Set information on entry to default "free" case.
  301. // Return S_OK
  302. //
  303. // History: 27-Aug-91 PhilipLa Created.
  304. // 07-Jan-92 PhilipLa Converted to use handle.
  305. // 20-Oct-92 AlexT Removed flags
  306. //
  307. // Notes:
  308. //
  309. //---------------------------------------------------------------------------
  310. inline SCODE CMStream::DestroyEntry(SID const sidParent,
  311. CDfName const *pdfn)
  312. {
  313. SCODE sc;
  314. msfDebugOut((DEB_ITRACE, "In CMStream::DestroyEntry()\n"));
  315. // Two cases:
  316. // pdfn == NULL - destroy all children of sidParent
  317. // pdfn != NULL - destroy the named child of sidParent
  318. if (pdfn == NULL)
  319. sc = _dir.DestroyAllChildren(sidParent, 0);
  320. else
  321. sc = _dir.DestroyChild(sidParent, pdfn, 0);
  322. msfDebugOut((DEB_ITRACE, "Out CMStream::DestroyEntry()\n"));
  323. return sc;
  324. }
  325. #ifdef USE_NOSCRATCH
  326. //+---------------------------------------------------------------------------
  327. //
  328. // Member: CMStream::SetNoScratchMS, public
  329. //
  330. // Synopsis: Set the multi-stream to use for NoScratch processing.
  331. //
  332. // Arguments: [pmsNoScratch] -- Pointer to NoScratch multistream
  333. //
  334. // Returns: void
  335. //
  336. // History: 10-Mar-95 PhilipLa Created
  337. //
  338. // Notes: This function is called on a base multistream during
  339. // the initialization path to indicate that the user has
  340. // opened using STGM_NOSCRATCH
  341. //
  342. //----------------------------------------------------------------------------
  343. inline void CMStream::SetScratchMS(CMStream *pmsNoScratch)
  344. {
  345. _pmsScratch = P_TO_BP(CBasedMStreamPtr, pmsNoScratch);
  346. _fat.SetNoScratch(pmsNoScratch->GetMiniFat());
  347. }
  348. #endif
  349. #endif //__MSFFUNC_HXX__