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.

492 lines
12 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992
  5. //
  6. // File: handle.hxx
  7. //
  8. // Contents: Defines CHandle
  9. //
  10. // Classes: CHandle
  11. // CStgHandle
  12. // CStmHandle
  13. //
  14. // History: 02-Jan-92 DrewB Created
  15. // 14-Jan-1992 PhilipL Added Handle Manager
  16. // 10-May-1992 DrewB Converted to use clump manager
  17. // 13-May-1992 AlexT Moved contents to msf.hxx
  18. // 21-Aug-1992 DrewB Redefined handles and
  19. // added new stg, stm versions
  20. //
  21. //---------------------------------------------------------------
  22. #ifndef __HANDLE_HXX__
  23. #define __HANDLE_HXX__
  24. #include <msf.hxx>
  25. #include <msffunc.hxx>
  26. //+--------------------------------------------------------------
  27. //
  28. // Class: CHandle (h)
  29. //
  30. // Purpose: An opaque handle to a directory entry-based object
  31. //
  32. // Interface: See below
  33. //
  34. // History: 21-Aug-92 DrewB Created
  35. //
  36. //---------------------------------------------------------------
  37. class CStgHandle;
  38. class CStmHandle;
  39. class CHandle
  40. {
  41. public:
  42. inline CHandle(void);
  43. inline void Init(CMStream *pms,
  44. SID sid);
  45. inline BOOL IsRoot(void) const;
  46. inline BOOL IsValid(void) const;
  47. inline SCODE DestroyEntry(CDfName const *pdfn);
  48. #ifdef HANDLERELEASE
  49. inline void Release(void);
  50. #endif
  51. inline CMStream *GetMS(void) const;
  52. inline SID GetSid(void) const;
  53. private:
  54. friend class CStgHandle;
  55. friend class CStmHandle;
  56. CBasedMStreamPtr _pms;
  57. SID _sid;
  58. };
  59. //+--------------------------------------------------------------
  60. //
  61. // Member: CHandle::CHandle, public
  62. //
  63. // Synopsis: NULL constructor
  64. //
  65. // History: 21-Aug-92 DrewB Created
  66. //
  67. //---------------------------------------------------------------
  68. inline CHandle::CHandle(void)
  69. {
  70. _pms = NULL;
  71. _sid = NOSTREAM;
  72. }
  73. //+--------------------------------------------------------------
  74. //
  75. // Member: CHandle::Init, public
  76. //
  77. // Synopsis: Sets internal data members
  78. //
  79. // Arguments: [pms] - Multistream
  80. // [sid] - SID
  81. //
  82. // Returns: Appropriate status code
  83. //
  84. // History: 21-Aug-92 DrewB Created
  85. //
  86. //---------------------------------------------------------------
  87. inline void CHandle::Init(CMStream *pms,
  88. SID sid)
  89. {
  90. _pms = P_TO_BP(CBasedMStreamPtr, pms);
  91. _sid = sid;
  92. }
  93. //+--------------------------------------------------------------
  94. //
  95. // Member: CHandle::IsRoot, public
  96. //
  97. // Synopsis: Whether this is a root handle or not
  98. //
  99. // History: 21-Aug-92 DrewB Created
  100. //
  101. //---------------------------------------------------------------
  102. inline BOOL CHandle::IsRoot(void) const
  103. {
  104. return _sid == SIDROOT;
  105. }
  106. //+--------------------------------------------------------------
  107. //
  108. // Member: CHandle::IsValid, public
  109. //
  110. // Synopsis: Whether this handle has been initialized
  111. //
  112. // History: 21-Aug-92 DrewB Created
  113. //
  114. //---------------------------------------------------------------
  115. inline BOOL CHandle::IsValid(void) const
  116. {
  117. return _pms != NULL;
  118. }
  119. //+--------------------------------------------------------------
  120. //
  121. // Member: CHandle::DestroyEntry, public
  122. //
  123. // Synopsis: Destroys this entry
  124. //
  125. // Returns: Appropriate status code
  126. //
  127. // History: 24-Aug-92 DrewB Created
  128. //
  129. //---------------------------------------------------------------
  130. inline SCODE CHandle::DestroyEntry(CDfName const *pdfn)
  131. {
  132. return _pms->DestroyEntry(_sid, pdfn);
  133. }
  134. #ifdef HANDLERELEASE
  135. //+--------------------------------------------------------------
  136. //
  137. // Member: CHandle::Release, public
  138. //
  139. // Synopsis: Releases the handle
  140. //
  141. // History: 24-Aug-92 DrewB Created
  142. //
  143. //---------------------------------------------------------------
  144. inline void CHandle::Release(void)
  145. {
  146. _pms->ReleaseEntry(_sid);
  147. }
  148. #endif
  149. //+--------------------------------------------------------------
  150. //
  151. // Member: CHandle::GetMS, public
  152. //
  153. // Synopsis: Returns the multistream
  154. //
  155. // History: 24-Aug-92 DrewB Created
  156. //
  157. //---------------------------------------------------------------
  158. inline CMStream * CHandle::GetMS(void) const
  159. {
  160. return BP_TO_P(CMStream *, _pms);
  161. }
  162. //+--------------------------------------------------------------
  163. //
  164. // Member: CHandle::GetSid, public
  165. //
  166. // Synopsis: Returns the sid
  167. //
  168. // History: 24-Aug-92 DrewB Created
  169. //
  170. //---------------------------------------------------------------
  171. inline SID CHandle::GetSid(void) const
  172. {
  173. return _sid;
  174. }
  175. //+--------------------------------------------------------------
  176. //
  177. // Class: CStgHandle, (stgh)
  178. //
  179. // Purpose: An opaque handle for Multistream directories
  180. //
  181. // Interface: See below
  182. //
  183. // History: 21-Aug-92 DrewB Created
  184. // 26-May-95 SusiA Added GetAllTimes
  185. // 22-Nov-95 SusiA Added SetAllTimes
  186. //
  187. //---------------------------------------------------------------
  188. class CStgHandle : public CHandle
  189. {
  190. public:
  191. inline SCODE CreateEntry(CDfName const *pdfnName,
  192. MSENTRYFLAGS const mefFlags,
  193. CHandle *ph);
  194. inline SCODE GetEntry(CDfName const *pdfnName,
  195. MSENTRYFLAGS const mefFlags,
  196. CHandle *ph);
  197. inline SCODE RenameEntry(CDfName const *pdfnName,
  198. CDfName const *pdfnNewName);
  199. inline SCODE IsEntry(CDfName const *pdfnName,
  200. SEntryBuffer *peb);
  201. inline SCODE GetClass(CLSID *pclsid);
  202. inline SCODE SetClass(REFCLSID clsid);
  203. inline SCODE GetStateBits(DWORD *pgrfStateBits);
  204. inline SCODE SetStateBits(DWORD grfStateBits, DWORD grfMask);
  205. inline SCODE GetTime(WHICHTIME wt, TIME_T *ptm);
  206. inline SCODE SetTime(WHICHTIME wt, TIME_T tm);
  207. inline SCODE GetAllTimes(TIME_T *patm,TIME_T *pmtm, TIME_T *pctm);
  208. inline SCODE SetAllTimes(TIME_T atm,TIME_T mtm, TIME_T ctm);
  209. };
  210. //+--------------------------------------------------------------
  211. //
  212. // Member: CStgHandle::CreateEntry, public
  213. //
  214. // Synopsis: Creates an entry
  215. //
  216. // History: 24-Aug-92 DrewB Created
  217. //
  218. //---------------------------------------------------------------
  219. inline SCODE CStgHandle::CreateEntry(CDfName const *pdfnName,
  220. MSENTRYFLAGS const mefFlags,
  221. CHandle *ph)
  222. {
  223. ph->_pms = _pms;
  224. return _pms->CreateEntry(_sid, pdfnName, mefFlags, &ph->_sid);
  225. }
  226. //+--------------------------------------------------------------
  227. //
  228. // Member: CStgHandle::GetEntry, public
  229. //
  230. // Synopsis: Gets an entry
  231. //
  232. // History: 24-Aug-92 DrewB Created
  233. //
  234. //---------------------------------------------------------------
  235. inline SCODE CStgHandle::GetEntry(CDfName const *pdfnName,
  236. MSENTRYFLAGS const mefFlags,
  237. CHandle *ph)
  238. {
  239. SCODE sc;
  240. SEntryBuffer eb;
  241. ph->_pms = _pms;
  242. sc = _pms->IsEntry(_sid, pdfnName, &eb);
  243. if (SUCCEEDED(sc))
  244. {
  245. msfAssert(eb.sid != NOSTREAM);
  246. // entry exists but it may be the wrong type
  247. if ((mefFlags != MEF_ANY) && (mefFlags != eb.dwType))
  248. {
  249. sc = STG_E_FILENOTFOUND;
  250. }
  251. else
  252. ph->_sid = eb.sid;
  253. }
  254. return(sc);
  255. }
  256. //+--------------------------------------------------------------
  257. //
  258. // Member: CStgHandle::RenameEntry, public
  259. //
  260. // Synopsis: Renames an entry
  261. //
  262. // History: 24-Aug-92 DrewB Created
  263. //
  264. //---------------------------------------------------------------
  265. inline SCODE CStgHandle::RenameEntry(CDfName const *pdfnName,
  266. CDfName const *pdfnNewName)
  267. {
  268. return _pms->RenameEntry(_sid, pdfnName, pdfnNewName);
  269. }
  270. //+--------------------------------------------------------------
  271. //
  272. // Member: CStgHandle::IsEntry, public
  273. //
  274. // Synopsis: Gets entry info and checks for existence
  275. //
  276. // History: 24-Aug-92 DrewB Created
  277. //
  278. //---------------------------------------------------------------
  279. inline SCODE CStgHandle::IsEntry(CDfName const *pdfnName,
  280. SEntryBuffer *peb)
  281. {
  282. return _pms->IsEntry(_sid, pdfnName, peb);
  283. }
  284. //+---------------------------------------------------------------------------
  285. //
  286. // Member: CStgHandle::GetClass, public
  287. //
  288. // Synopsis: Gets the class ID
  289. //
  290. // History: 11-Nov-92 DrewB Created
  291. //
  292. //----------------------------------------------------------------------------
  293. inline SCODE CStgHandle::GetClass(CLSID *pclsid)
  294. {
  295. return _pms->GetClass(_sid, pclsid);
  296. }
  297. //+---------------------------------------------------------------------------
  298. //
  299. // Member: CStgHandle::SetClass, public
  300. //
  301. // Synopsis: Sets the class ID
  302. //
  303. // History: 11-Nov-92 DrewB Created
  304. //
  305. //----------------------------------------------------------------------------
  306. inline SCODE CStgHandle::SetClass(REFCLSID clsid)
  307. {
  308. return _pms->SetClass(_sid, clsid);
  309. }
  310. //+---------------------------------------------------------------------------
  311. //
  312. // Member: CStgHandle::GetStateBits, public
  313. //
  314. // Synopsis: Gets state bits
  315. //
  316. // History: 11-Nov-92 DrewB Created
  317. //
  318. //----------------------------------------------------------------------------
  319. inline SCODE CStgHandle::GetStateBits(DWORD *pgrfStateBits)
  320. {
  321. return _pms->GetStateBits(_sid, pgrfStateBits);
  322. }
  323. //+---------------------------------------------------------------------------
  324. //
  325. // Member: CStgHandle::SetStateBits, public
  326. //
  327. // Synopsis: Sets state bits
  328. //
  329. // History: 11-Nov-92 DrewB Created
  330. //
  331. //----------------------------------------------------------------------------
  332. inline SCODE CStgHandle::SetStateBits(DWORD grfStateBits, DWORD grfMask)
  333. {
  334. return _pms->SetStateBits(_sid, grfStateBits, grfMask);
  335. }
  336. //+--------------------------------------------------------------
  337. //
  338. // Member: CStgHandle::GetTime, public
  339. //
  340. // Synopsis: Returns the time
  341. //
  342. // History: 28-Jul-92 DrewB Created
  343. //
  344. //---------------------------------------------------------------
  345. inline SCODE CStgHandle::GetTime(WHICHTIME wt, TIME_T *ptm)
  346. {
  347. return _pms->GetTime(_sid, wt, ptm);
  348. }
  349. //+--------------------------------------------------------------
  350. //
  351. // Member: CStgHandle::GetAllTimes, public
  352. //
  353. // Synopsis: Returns all the times
  354. //
  355. // History: 26-May-95 SusiA Created
  356. //
  357. //---------------------------------------------------------------
  358. inline SCODE CStgHandle::GetAllTimes(TIME_T *patm,TIME_T *pmtm, TIME_T *pctm )
  359. {
  360. return _pms->GetAllTimes(_sid, patm, pmtm, pctm);
  361. }
  362. //+--------------------------------------------------------------
  363. //
  364. // Member: CStgHandle::SetAllTimes, public
  365. //
  366. // Synopsis: Sets all the times
  367. //
  368. // History: 26-May-95 SusiA Created
  369. //
  370. //---------------------------------------------------------------
  371. inline SCODE CStgHandle::SetAllTimes(TIME_T atm,TIME_T mtm, TIME_T ctm )
  372. {
  373. return _pms->SetAllTimes(_sid, atm, mtm, ctm);
  374. }
  375. //+--------------------------------------------------------------
  376. //
  377. // Member: CStgHandle::SetTime, public
  378. //
  379. // Synopsis: Sets the time
  380. //
  381. // History: 28-Jul-92 DrewB Created
  382. //
  383. //---------------------------------------------------------------
  384. inline SCODE CStgHandle::SetTime(WHICHTIME wt, TIME_T tm)
  385. {
  386. return _pms->SetTime(_sid, wt, tm);
  387. }
  388. //+--------------------------------------------------------------
  389. //
  390. // Class: CStmHandle, (stmh)
  391. //
  392. // Purpose: An opaque handle for Multistream streams
  393. //
  394. // Interface: See below
  395. //
  396. // History: 21-Aug-92 DrewB Created
  397. //
  398. //---------------------------------------------------------------
  399. class CDirectStream;
  400. class CStmHandle : public CHandle
  401. {
  402. public:
  403. #ifdef LARGE_STREAMS
  404. inline SCODE GetSize(ULONGLONG *pcbSize);
  405. #else
  406. inline SCODE GetSize(ULONG *pcbSize);
  407. #endif
  408. };
  409. //+--------------------------------------------------------------
  410. //
  411. // Member: CStmHandle::GetSize, public
  412. //
  413. // Synopsis: Gets the stream size
  414. //
  415. // History: 25-Aug-92 DrewB Created
  416. //
  417. //---------------------------------------------------------------
  418. #ifdef LARGE_STREAMS
  419. inline SCODE CStmHandle::GetSize(ULONGLONG *pcbSize)
  420. #else
  421. inline SCODE CStmHandle::GetSize(ULONG *pcbSize)
  422. #endif
  423. {
  424. return _pms->GetEntrySize(_sid, pcbSize);
  425. }
  426. #endif // #ifndef __HANDLE_HXX__