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.

284 lines
7.1 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: stream.hxx
  7. //
  8. // Contents: Stream header for mstream project
  9. //
  10. // Classes: CSStream - single linear stream for MSF
  11. //
  12. // History: 18-Jul-91 Philipla Created.
  13. //
  14. //--------------------------------------------------------------------
  15. #ifndef __STREAM_HXX__
  16. #define __STREAM_HXX__
  17. #include <msf.hxx>
  18. #include <handle.hxx>
  19. #include <tset.hxx>
  20. #include <psstream.hxx>
  21. #include <dfbasis.hxx>
  22. #include <cache.hxx>
  23. #include <dl.hxx>
  24. //+----------------------------------------------------------------------
  25. //
  26. // Class: CDirectStream (ds)
  27. //
  28. // Purpose: Direct stream class
  29. //
  30. // History: 18-Jul-91 PhilipLa Created.
  31. //
  32. // Notes:
  33. //
  34. //-----------------------------------------------------------------------
  35. class CDirectStream: public PSStream, public CMallocBased
  36. {
  37. public:
  38. inline void *operator new(size_t size, IMalloc * const pMalloc);
  39. inline void *operator new(size_t size, CDFBasis * const pdfb);
  40. inline void ReturnToReserve(CDFBasis * const pdfb);
  41. inline static SCODE Reserve(UINT cItems, CDFBasis * const pdfb);
  42. inline static void Unreserve(UINT cItems, CDFBasis * const pdfb);
  43. CDirectStream(DFLUID dl);
  44. ~CDirectStream(void);
  45. void InitSystem(CMStream *pms,
  46. SID sid,
  47. #ifdef LARGE_STREAMS
  48. ULONGLONG cbSize);
  49. #else
  50. ULONG cbSize);
  51. #endif
  52. SCODE Init(CStgHandle *pstgh,
  53. CDfName const *pdfn,
  54. BOOL const fCreate);
  55. inline void DecRef(VOID);
  56. SCODE BeginCommitFromChild(
  57. #ifdef LARGE_STREAMS
  58. ULONGLONG ulSize,
  59. #else
  60. ULONG ulSize,
  61. #endif
  62. CDeltaList *pDelta,
  63. CTransactedStream *pstChild);
  64. void EndCommitFromChild(DFLAGS df,
  65. CTransactedStream *pstChild);
  66. CDeltaList * GetDeltaList(void);
  67. SCODE ReadAt(
  68. #ifdef LARGE_STREAMS
  69. ULONGLONG ulOffset,
  70. #else
  71. ULONG ulOffset,
  72. #endif
  73. VOID *pBuffer,
  74. ULONG ulCount,
  75. ULONG STACKBASED *pulRetval);
  76. SCODE WriteAt(
  77. #ifdef LARGE_STREAMS
  78. ULONGLONG ulOffset,
  79. #else
  80. ULONG ulOffset,
  81. #endif
  82. VOID const *pBuffer,
  83. ULONG ulCount,
  84. ULONG STACKBASED *pulRetval);
  85. #ifdef LARGE_STREAMS
  86. SCODE SetSize(ULONGLONG ulNewSize);
  87. void GetSize(ULONGLONG *pulSize);
  88. #else
  89. SCODE SetSize(ULONG ulNewSize);
  90. void GetSize(ULONG *pulSize);
  91. #endif
  92. // PBasicEntry
  93. inline CStmHandle *GetHandle(void);
  94. inline void EmptyCache (void);
  95. private:
  96. #ifdef SECURE_STREAMS
  97. #ifdef LARGE_STREAMS
  98. void ClearSects(ULONGLONG ulStartOffset, ULONGLONG ulEndOffset);
  99. ULONGLONG _ulHighWater;
  100. #else
  101. void ClearSects(ULONG ulStartOffset, ULONG ulEndOffset);
  102. ULONG _ulHighWater;
  103. #endif
  104. #endif
  105. CStmHandle _stmh;
  106. CStreamCache _stmc;
  107. #ifdef LARGE_STREAMS
  108. ULONGLONG _ulSize;
  109. ULONGLONG _ulOldSize;
  110. #else
  111. ULONG _ulSize;
  112. ULONG _ulOldSize;
  113. #endif
  114. CBasedDeltaListPtr _pdlHolder;
  115. };
  116. //+--------------------------------------------------------------
  117. //
  118. // Member: CDirectStream::operator new, public
  119. //
  120. // Synopsis: Unreserved object allocator
  121. //
  122. // Arguments: [size] -- byte count to allocate
  123. // [pMalloc] -- allocator
  124. //
  125. // History: 25-May-93 AlexT Created
  126. //
  127. //---------------------------------------------------------------
  128. inline void *CDirectStream::operator new(size_t size, IMalloc * const pMalloc)
  129. {
  130. return(CMallocBased::operator new(size, pMalloc));
  131. }
  132. //+--------------------------------------------------------------
  133. //
  134. // Member: CDirectStream::operator new, public
  135. //
  136. // Synopsis: Reserved object allocator
  137. //
  138. // Arguments: [size] -- byte count to allocate
  139. // [pdfb] -- basis
  140. //
  141. // History: 25-May-93 AlexT Created
  142. //
  143. //---------------------------------------------------------------
  144. inline void *CDirectStream::operator new(size_t size, CDFBasis * const pdfb)
  145. {
  146. olAssert(size == sizeof(CDirectStream));
  147. return pdfb->GetFreeList(CDFB_DIRECTSTREAM)->GetReserved();
  148. }
  149. //+--------------------------------------------------------------
  150. //
  151. // Member: CDirectStream::ReturnToReserve, public
  152. //
  153. // Synopsis: Reserved object return
  154. //
  155. // Arguments: [pdfb] -- basis
  156. //
  157. // History: 25-May-93 AlexT Created
  158. //
  159. //---------------------------------------------------------------
  160. inline void CDirectStream::ReturnToReserve(CDFBasis * const pdfb)
  161. {
  162. CDirectStream::~CDirectStream();
  163. pdfb->GetFreeList(CDFB_DIRECTSTREAM)->ReturnToReserve(this);
  164. }
  165. //+--------------------------------------------------------------
  166. //
  167. // Member: CDirectStream::Reserve, public
  168. //
  169. // Synopsis: Reserve instances
  170. //
  171. // Arguments: [cItems] -- count of items
  172. // [pdfb] -- basis
  173. //
  174. // History: 25-May-93 AlexT Created
  175. //
  176. //---------------------------------------------------------------
  177. inline SCODE CDirectStream::Reserve(UINT cItems, CDFBasis * const pdfb)
  178. {
  179. return pdfb->Reserve(cItems, CDFB_DIRECTSTREAM);
  180. }
  181. //+--------------------------------------------------------------
  182. //
  183. // Member: CDirectStream::Unreserve, public
  184. //
  185. // Synopsis: Unreserve instances
  186. //
  187. // Arguments: [cItems] -- count of items
  188. // [pdfb] -- basis
  189. //
  190. // History: 25-May-93 AlexT Created
  191. //
  192. //---------------------------------------------------------------
  193. inline void CDirectStream::Unreserve(UINT cItems, CDFBasis * const pdfb)
  194. {
  195. pdfb->Unreserve(cItems, CDFB_DIRECTSTREAM);
  196. }
  197. //+---------------------------------------------------------------------------
  198. //
  199. // Member: CDirectStream::GetHandle, public
  200. //
  201. // Synopsis: Returns a pointer to the stream handle
  202. //
  203. // History: 25-Jun-92 DrewB Created
  204. //
  205. //----------------------------------------------------------------------------
  206. inline CStmHandle *CDirectStream::GetHandle(void)
  207. {
  208. return &_stmh;
  209. }
  210. //+---------------------------------------------------------------------------
  211. //
  212. // Member: CDirectStream::DecRef, public
  213. //
  214. // Synopsis: Decrements the ref count
  215. //
  216. // History: 25-Nov-92 DrewB Created
  217. //
  218. //----------------------------------------------------------------------------
  219. inline void CDirectStream::DecRef(void)
  220. {
  221. AtomicDec(&_cReferences);
  222. }
  223. //+---------------------------------------------------------------------------
  224. //
  225. // Member: CDirectStream::EmptyCache, public
  226. //
  227. // Synopsis: Empties the stream cache
  228. //
  229. // History: 27-Jul-1999 HenryLee Created
  230. //
  231. //----------------------------------------------------------------------------
  232. inline void CDirectStream::EmptyCache (void)
  233. {
  234. _stmc.Empty();
  235. }
  236. #endif //__SSTREAM_HXX__