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.

629 lines
18 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: entry.cxx
  7. //
  8. // Contents: Entry implementations
  9. //
  10. // History: 29-Jul-92 DrewB Created
  11. // 10-Apr-95 HenryLee remove Sleep
  12. //
  13. //---------------------------------------------------------------
  14. #include <dfhead.cxx>
  15. #include <smalloc.hxx>
  16. #pragma hdrstop
  17. #define PDOCFILE_VCALL(x) \
  18. if (_sig == CDOCFILE_SIG) \
  19. return ((CDocFile *)this)->x; \
  20. else if (_sig == CWRAPPEDDOCFILE_SIG) \
  21. return ((CWrappedDocFile *)this)->x; \
  22. else olAssert (!"Invalid signature on PDocFile!");\
  23. return STG_E_INVALIDFUNCTION;
  24. #define PSSTREAM_VCALL(x) \
  25. if (_sig == CDIRECTSTREAM_SIG) \
  26. return ((CDirectStream *)this)->x; \
  27. else if (_sig == CTRANSACTEDSTREAM_SIG) \
  28. return ((CTransactedStream *)this)->x; \
  29. else olAssert (!"Invalid signature on PSStream!");\
  30. return STG_E_INVALIDFUNCTION;
  31. #define PTIMEENTRY_VCALL(x) \
  32. if (_sig == CDOCFILE_SIG) \
  33. return ((CDocFile *)this)->x; \
  34. else if (_sig == CWRAPPEDDOCFILE_SIG) \
  35. return ((CWrappedDocFile *)this)->x; \
  36. else olAssert (!"Invalid signature on PTimeEntry");\
  37. return STG_E_INVALIDFUNCTION;
  38. //+--------------------------------------------------------------
  39. //
  40. // Member: PTimeEntry::CopyTimesFrom, public
  41. //
  42. // Synopsis: Copies one entries times to another
  43. //
  44. // Arguments: [ptenFrom] - From
  45. //
  46. // Returns: Appropriate status code
  47. //
  48. // History: 29-Jul-92 DrewB Created
  49. // 26-May-95 SusiA Removed GetTime; Added GetAllTimes
  50. // 22-Nov-95 SusiA SetAllTimes at once
  51. //
  52. //---------------------------------------------------------------
  53. SCODE PTimeEntry::CopyTimesFrom(PTimeEntry *ptenFrom)
  54. {
  55. SCODE sc;
  56. TIME_T atm; //Access time
  57. TIME_T mtm; //Modification time
  58. TIME_T ctm; //Creation time
  59. olDebugOut((DEB_ITRACE, "In PTimeEntry::CopyTimesFrom(%p)\n",
  60. ptenFrom));
  61. olChk(ptenFrom->GetAllTimes(&atm, &mtm, &ctm));
  62. olChk(SetAllTimes(atm, mtm, ctm));
  63. olDebugOut((DEB_ITRACE, "Out PTimeEntry::CopyTimesFrom\n"));
  64. // Fall through
  65. EH_Err:
  66. return sc;
  67. }
  68. //+--------------------------------------------------------------
  69. //
  70. // Member: PBasicEntry::GetNewLuid, public
  71. //
  72. // Synopsis: Returns a new luid
  73. //
  74. // History: 21-Oct-92 AlexT Created
  75. //
  76. //---------------------------------------------------------------
  77. //We used to have a mutex here - it turns out that this is unnecessary,
  78. // since we're already holding the tree mutex. We get a performance
  79. // win by eliminating the mutex.
  80. DFLUID PBasicEntry::GetNewLuid(const IMalloc *pMalloc)
  81. {
  82. DFLUID luid;
  83. luid = ((CSmAllocator *)pMalloc)->IncrementLuid();
  84. return luid;
  85. }
  86. //+--------------------------------------------------------------
  87. //
  88. // Member: PTimeEntry::GetTime, public
  89. //
  90. // Synopsis: calls to derived object
  91. //
  92. // History: 20-Jan-98 HenryLee Created
  93. //
  94. //---------------------------------------------------------------
  95. SCODE PTimeEntry::GetTime(WHICHTIME wt, TIME_T *ptm)
  96. {
  97. PTIMEENTRY_VCALL (GetTime (wt, ptm));
  98. }
  99. //+--------------------------------------------------------------
  100. //
  101. // Member: PTimeEntry::SetTime, public
  102. //
  103. // Synopsis: calls to derived object
  104. //
  105. // History: 20-Jan-98 HenryLee Created
  106. //
  107. //---------------------------------------------------------------
  108. SCODE PTimeEntry::SetTime(WHICHTIME wt, TIME_T tm)
  109. {
  110. PTIMEENTRY_VCALL (SetTime (wt, tm));
  111. }
  112. //+--------------------------------------------------------------
  113. //
  114. // Member: PTimeEntry::GetAllTimes, public
  115. //
  116. // Synopsis: calls to derived object
  117. //
  118. // History: 20-Jan-98 HenryLee Created
  119. //
  120. //---------------------------------------------------------------
  121. SCODE PTimeEntry::GetAllTimes(TIME_T *patm, TIME_T *pmtm, TIME_T *pctm)
  122. {
  123. PTIMEENTRY_VCALL (GetAllTimes (patm, pmtm, pctm));
  124. }
  125. //+--------------------------------------------------------------
  126. //
  127. // Member: PTimeEntry::SetTime, public
  128. //
  129. // Synopsis: calls to derived object
  130. //
  131. // History: 20-Jan-98 HenryLee Created
  132. //
  133. //---------------------------------------------------------------
  134. SCODE PTimeEntry::SetAllTimes(TIME_T atm, TIME_T mtm, TIME_T ctm)
  135. {
  136. PTIMEENTRY_VCALL (SetAllTimes (atm, mtm, ctm));
  137. }
  138. //+--------------------------------------------------------------
  139. //
  140. // Member: PBasicEntry::Release, public
  141. //
  142. // Synopsis: Release resources for a PBasicEntry
  143. //
  144. // History: 11-Dec-91 DrewB Created
  145. //
  146. //---------------------------------------------------------------
  147. void PBasicEntry::Release(void)
  148. {
  149. LONG lRet;
  150. olDebugOut((DEB_ITRACE, "In PBasicEntry::Release()\n"));
  151. olAssert(_cReferences > 0);
  152. lRet = AtomicDec(&_cReferences);
  153. if (lRet == 0)
  154. {
  155. if (_sig == CDOCFILE_SIG)
  156. delete (CDocFile *)this;
  157. else if (_sig == CWRAPPEDDOCFILE_SIG)
  158. delete (CWrappedDocFile *)this;
  159. else if (_sig == CDIRECTSTREAM_SIG)
  160. delete (CDirectStream *)this;
  161. else if (_sig == CTRANSACTEDSTREAM_SIG)
  162. delete (CTransactedStream *)this;
  163. else
  164. olAssert (!"Invalid signature on PBasicEntry!");
  165. }
  166. olDebugOut((DEB_ITRACE, "Out PBasicEntry::Release\n"));
  167. }
  168. //+--------------------------------------------------------------
  169. //
  170. // Member: PSStream::BeginCommitFromChild, public
  171. //
  172. // Synopsis: calls to derived object
  173. //
  174. // History: 20-Jan-98 HenryLee Created
  175. //
  176. //---------------------------------------------------------------
  177. SCODE PSStream::BeginCommitFromChild(
  178. #ifdef LARGE_STREAMS
  179. ULONGLONG ulSize,
  180. #else
  181. ULONG ulSize,
  182. #endif
  183. CDeltaList *pDelta,
  184. CTransactedStream *pstChild)
  185. {
  186. PSSTREAM_VCALL (BeginCommitFromChild (ulSize, pDelta, pstChild));
  187. }
  188. //+--------------------------------------------------------------
  189. //
  190. // Member: PSStream::EndCommitFromChild, public
  191. //
  192. // Synopsis: calls to derived object
  193. //
  194. // History: 20-Jan-98 HenryLee Created
  195. //
  196. //---------------------------------------------------------------
  197. void PSStream::EndCommitFromChild(DFLAGS df, CTransactedStream *pstChild)
  198. {
  199. if (_sig == CDIRECTSTREAM_SIG)
  200. ((CDirectStream *)this)->EndCommitFromChild (df, pstChild);
  201. else if (_sig == CTRANSACTEDSTREAM_SIG)
  202. ((CTransactedStream *)this)->EndCommitFromChild (df, pstChild);
  203. else olAssert (!"Invalid signature on PSStream!");
  204. return;
  205. }
  206. //+--------------------------------------------------------------
  207. //
  208. // Member: PSStream::EmptyCache, public
  209. //
  210. // Synopsis: calls to derived object
  211. //
  212. // History: 20-Jan-98 HenryLee Created
  213. //
  214. //---------------------------------------------------------------
  215. void PSStream::EmptyCache()
  216. {
  217. if (_sig == CDIRECTSTREAM_SIG)
  218. ((CDirectStream *)this)->EmptyCache();
  219. else if (_sig == CTRANSACTEDSTREAM_SIG)
  220. ((CTransactedStream *)this)->EmptyCache();
  221. else olAssert (!"Invalid signature on PSStream!");
  222. return;
  223. }
  224. //+--------------------------------------------------------------
  225. //
  226. // Member: PSStream::GetDeltaList, public
  227. //
  228. // Synopsis: calls to derived object
  229. //
  230. // History: 20-Jan-98 HenryLee Created
  231. //
  232. //---------------------------------------------------------------
  233. CDeltaList * PSStream::GetDeltaList(void)
  234. {
  235. if (_sig == CDIRECTSTREAM_SIG)
  236. return ((CDirectStream *)this)->GetDeltaList ();
  237. else if (_sig == CTRANSACTEDSTREAM_SIG)
  238. return ((CTransactedStream *)this)->GetDeltaList ();
  239. else olAssert (!"Invalid signature on PSStream!");
  240. return NULL;
  241. }
  242. //+--------------------------------------------------------------
  243. //
  244. // Member: PSStream::ReadAt, public
  245. //
  246. // Synopsis: calls to derived object
  247. //
  248. // History: 20-Jan-98 HenryLee Created
  249. //
  250. //---------------------------------------------------------------
  251. SCODE PSStream::ReadAt(
  252. #ifdef LARGE_STREAMS
  253. ULONGLONG ulOffset,
  254. #else
  255. ULONG ulOffset,
  256. #endif
  257. VOID *pBuffer,
  258. ULONG ulCount,
  259. ULONG STACKBASED *pulRetval)
  260. {
  261. PSSTREAM_VCALL (ReadAt (ulOffset, pBuffer, ulCount, pulRetval));
  262. }
  263. //+--------------------------------------------------------------
  264. //
  265. // Member: PSStream::WriteAt, public
  266. //
  267. // Synopsis: calls to derived object
  268. //
  269. // History: 20-Jan-98 HenryLee Created
  270. //
  271. //---------------------------------------------------------------
  272. SCODE PSStream::WriteAt(
  273. #ifdef LARGE_STREAMS
  274. ULONGLONG ulOffset,
  275. #else
  276. ULONG ulOffset,
  277. #endif
  278. VOID const *pBuffer,
  279. ULONG ulCount,
  280. ULONG STACKBASED *pulRetval)
  281. {
  282. PSSTREAM_VCALL (WriteAt (ulOffset, pBuffer, ulCount, pulRetval));
  283. }
  284. //+--------------------------------------------------------------
  285. //
  286. // Member: PSStream::SetSize, public
  287. //
  288. // Synopsis: calls to derived object
  289. //
  290. // History: 20-Jan-98 HenryLee Created
  291. //
  292. //---------------------------------------------------------------
  293. #ifdef LARGE_STREAMS
  294. SCODE PSStream::SetSize(ULONGLONG ulNewSize)
  295. #else
  296. SCODE PSStream::SetSize(ULONG ulNewSize)
  297. #endif
  298. {
  299. PSSTREAM_VCALL (SetSize (ulNewSize));
  300. }
  301. //+--------------------------------------------------------------
  302. //
  303. // Member: PSStream::GetSize, public
  304. //
  305. // Synopsis: calls to derived object
  306. //
  307. // History: 20-Jan-98 HenryLee Created
  308. //
  309. //---------------------------------------------------------------
  310. #ifdef LARGE_STREAMS
  311. void PSStream::GetSize(ULONGLONG *pulSize)
  312. #else
  313. void PSStream::GetSize(ULONG *pulSize)
  314. #endif
  315. {
  316. if (_sig == CDIRECTSTREAM_SIG)
  317. ((CDirectStream *)this)->GetSize (pulSize);
  318. else if (_sig == CTRANSACTEDSTREAM_SIG)
  319. ((CTransactedStream *)this)->GetSize (pulSize);
  320. else olAssert (!"Invalid signature on PSStream!");
  321. return;
  322. }
  323. //+--------------------------------------------------------------
  324. //
  325. // Member: PDocFile::DestroyEntry, public
  326. //
  327. // Synopsis: calls to derived object
  328. //
  329. // History: 20-Jan-98 HenryLee Created
  330. //
  331. //---------------------------------------------------------------
  332. SCODE PDocFile::DestroyEntry(CDfName const *pdfnName,
  333. BOOL fClean)
  334. {
  335. PDOCFILE_VCALL (DestroyEntry(pdfnName, fClean));
  336. }
  337. //+--------------------------------------------------------------
  338. //
  339. // Member: PDocFile::RenameEntry, public
  340. //
  341. // Synopsis: calls to derived object
  342. //
  343. // History: 20-Jan-98 HenryLee Created
  344. //
  345. //---------------------------------------------------------------
  346. SCODE PDocFile::RenameEntry(CDfName const *pdfnName,
  347. CDfName const *pdfnNewName)
  348. {
  349. PDOCFILE_VCALL (RenameEntry (pdfnName, pdfnNewName));
  350. }
  351. //+--------------------------------------------------------------
  352. //
  353. // Member: PDocFile::GetClass, public
  354. //
  355. // Synopsis: calls to derived object
  356. //
  357. // History: 20-Jan-98 HenryLee Created
  358. //
  359. //---------------------------------------------------------------
  360. SCODE PDocFile::GetClass(CLSID *pclsid)
  361. {
  362. PDOCFILE_VCALL (GetClass (pclsid));
  363. }
  364. //+--------------------------------------------------------------
  365. //
  366. // Member: PDocFile::SetClass, public
  367. //
  368. // Synopsis: calls to derived object
  369. //
  370. // History: 20-Jan-98 HenryLee Created
  371. //
  372. //---------------------------------------------------------------
  373. SCODE PDocFile::SetClass(REFCLSID clsid)
  374. {
  375. PDOCFILE_VCALL (SetClass (clsid));
  376. }
  377. //+--------------------------------------------------------------
  378. //
  379. // Member: PDocFile::GetStateBits, public
  380. //
  381. // Synopsis: calls to derived object
  382. //
  383. // History: 20-Jan-98 HenryLee Created
  384. //
  385. //---------------------------------------------------------------
  386. SCODE PDocFile::GetStateBits(DWORD *pgrfStateBits)
  387. {
  388. PDOCFILE_VCALL (GetStateBits (pgrfStateBits));
  389. }
  390. //+--------------------------------------------------------------
  391. //
  392. // Member: PDocFile::SetStateBits, public
  393. //
  394. // Synopsis: calls to derived object
  395. //
  396. // History: 20-Jan-98 HenryLee Created
  397. //
  398. //---------------------------------------------------------------
  399. SCODE PDocFile::SetStateBits(DWORD grfStateBits, DWORD grfMask)
  400. {
  401. PDOCFILE_VCALL (SetStateBits (grfStateBits, grfMask));
  402. }
  403. //+--------------------------------------------------------------
  404. //
  405. // Member: PDocFile::CreateDocFile, public
  406. //
  407. // Synopsis: calls to derived object
  408. //
  409. // History: 20-Jan-98 HenryLee Created
  410. //
  411. //---------------------------------------------------------------
  412. SCODE PDocFile::CreateDocFile(CDfName const *pdfnName,
  413. DFLAGS const df,
  414. DFLUID luidSet,
  415. PDocFile **ppdfDocFile)
  416. {
  417. PDOCFILE_VCALL (CreateDocFile (pdfnName, df, luidSet, ppdfDocFile));
  418. }
  419. //+--------------------------------------------------------------
  420. //
  421. // Member: PDocFile::GetDocFile, public
  422. //
  423. // Synopsis: calls to derived object
  424. //
  425. // History: 20-Jan-98 HenryLee Created
  426. //
  427. //---------------------------------------------------------------
  428. SCODE PDocFile::GetDocFile(CDfName const *pdfnName,
  429. DFLAGS const df,
  430. PDocFile **ppdfDocFile)
  431. {
  432. PDOCFILE_VCALL (GetDocFile (pdfnName, df, ppdfDocFile));
  433. }
  434. //+--------------------------------------------------------------
  435. //
  436. // Member: PDocFile::CreateStream, public
  437. //
  438. // Synopsis: calls to derived object
  439. //
  440. // History: 20-Jan-98 HenryLee Created
  441. //
  442. //---------------------------------------------------------------
  443. SCODE PDocFile::CreateStream(CDfName const *pdfnName,
  444. DFLAGS const df,
  445. DFLUID luidSet,
  446. PSStream **ppsstStream)
  447. {
  448. PDOCFILE_VCALL (CreateStream (pdfnName, df, luidSet, ppsstStream));
  449. }
  450. //+--------------------------------------------------------------
  451. //
  452. // Member: PDocFile::GetStream, public
  453. //
  454. // Synopsis: calls to derived object
  455. //
  456. // History: 20-Jan-98 HenryLee Created
  457. //
  458. //---------------------------------------------------------------
  459. SCODE PDocFile::GetStream(CDfName const *pdfnName,
  460. DFLAGS const df,
  461. PSStream **ppsstStream)
  462. {
  463. PDOCFILE_VCALL (GetStream (pdfnName, df, ppsstStream));
  464. }
  465. //+--------------------------------------------------------------
  466. //
  467. // Member: PDocFile::FindGreaterEntry, public
  468. //
  469. // Synopsis: calls to derived object
  470. //
  471. // History: 20-Jan-98 HenryLee Created
  472. //
  473. //---------------------------------------------------------------
  474. SCODE PDocFile::FindGreaterEntry(CDfName const *pdfnKey,
  475. SIterBuffer *pib,
  476. STATSTGW *pstat)
  477. {
  478. PDOCFILE_VCALL (FindGreaterEntry (pdfnKey, pib, pstat));
  479. }
  480. //+--------------------------------------------------------------
  481. //
  482. // Member: PDocFile::StatEntry, public
  483. //
  484. // Synopsis: calls to derived object
  485. //
  486. // History: 20-Jan-98 HenryLee Created
  487. //
  488. //---------------------------------------------------------------
  489. SCODE PDocFile::StatEntry(CDfName const *pdfn,
  490. SIterBuffer *pib,
  491. STATSTGW *pstat)
  492. {
  493. PDOCFILE_VCALL (StatEntry (pdfn, pib, pstat));
  494. }
  495. //+--------------------------------------------------------------
  496. //
  497. // Member: PDocFile::BeginCommitFromChild, public
  498. //
  499. // Synopsis: calls to derived object
  500. //
  501. // History: 20-Jan-98 HenryLee Created
  502. //
  503. //---------------------------------------------------------------
  504. SCODE PDocFile::BeginCommitFromChild(CUpdateList &ulChanged,
  505. DWORD const dwFlags,
  506. CWrappedDocFile *pdfChild)
  507. {
  508. PDOCFILE_VCALL (BeginCommitFromChild (ulChanged, dwFlags, pdfChild));
  509. }
  510. //+--------------------------------------------------------------
  511. //
  512. // Member: PDocFile::EndCommitFromChild, public
  513. //
  514. // Synopsis: calls to derived object
  515. //
  516. // History: 20-Jan-98 HenryLee Created
  517. //
  518. //---------------------------------------------------------------
  519. void PDocFile::EndCommitFromChild(DFLAGS const df,
  520. CWrappedDocFile *pdfChild)
  521. {
  522. if (_sig == CDOCFILE_SIG)
  523. ((CDocFile *)this)->EndCommitFromChild (df, pdfChild);
  524. else if (_sig == CWRAPPEDDOCFILE_SIG)
  525. ((CWrappedDocFile *)this)->EndCommitFromChild (df, pdfChild);
  526. else olAssert (!"Invalid signature on PTimeEntry!");
  527. return;
  528. }
  529. //+--------------------------------------------------------------
  530. //
  531. // Member: PDocFile::IsEntry, public
  532. //
  533. // Synopsis: calls to derived object
  534. //
  535. // History: 20-Jan-98 HenryLee Created
  536. //
  537. //---------------------------------------------------------------
  538. SCODE PDocFile::IsEntry(CDfName const *pdfnName,
  539. SEntryBuffer *peb)
  540. {
  541. PDOCFILE_VCALL (IsEntry (pdfnName, peb));
  542. }
  543. //+--------------------------------------------------------------
  544. //
  545. // Member: PDocFile::DeleteContents, public
  546. //
  547. // Synopsis: calls to derived object
  548. //
  549. // History: 20-Jan-98 HenryLee Created
  550. //
  551. //---------------------------------------------------------------
  552. SCODE PDocFile::DeleteContents(void)
  553. {
  554. PDOCFILE_VCALL (DeleteContents());
  555. }