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.

187 lines
4.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: difat.hxx
  7. //
  8. // Contents: Double-indirect Fat class headers
  9. //
  10. // Classes: CDIFat
  11. // CDIFatVector
  12. //
  13. // Functions:
  14. //
  15. // History: 02-Sep-92 PhilipLa Created.
  16. //
  17. //--------------------------------------------------------------------------
  18. #ifndef __DIFAT_HXX__
  19. #define __DIFAT_HXX__
  20. //+-------------------------------------------------------------------------
  21. //
  22. // Class: CDIFat (dif)
  23. //
  24. // Purpose: Double Indirect Fat class for MSF
  25. //
  26. // Interface: See below.
  27. //
  28. // History: 11-May-92 PhilipLa Created.
  29. //
  30. //--------------------------------------------------------------------------
  31. class CDIFat
  32. {
  33. public:
  34. CDIFat();
  35. CDIFat(CDIFat *pfatOld);
  36. inline ~CDIFat();
  37. VOID Empty(VOID);
  38. SCODE GetFatSect(const FSINDEX oSect, SECT *psect);
  39. SCODE SetFatSect(const FSINDEX oSect, const SECT sect);
  40. SCODE GetSect(const FSINDEX oSect, SECT *psect);
  41. SCODE Init(CMStream *pmsParent, const FSINDEX cFatSect);
  42. inline void InitCopy(CDIFat *pfatOld);
  43. SCODE InitConvert(CMStream *pmsParent, SECT sectMax);
  44. SCODE InitNew(CMStream *pmsParent);
  45. SCODE Lookup(const SECT sect, SECT *psectRet);
  46. SCODE Fixup(CMStream * pmsShadow);
  47. SCODE Remap(const FSINDEX oSect, SECT *psectReturn);
  48. SCODE RemapSelf(VOID);
  49. SCODE Flush(void);
  50. #ifdef DIFAT_LOOKUP_ARRAY
  51. inline void CacheUnmarkedSect(SECT sectNew, SECT sectMark, SECT sectFree);
  52. #endif
  53. inline void SetParent(CMStream *pms);
  54. private:
  55. CFatVector _fv;
  56. CBasedMStreamPtr _pmsParent;
  57. FSINDEX _cfsTable;
  58. #ifdef DIFAT_LOOKUP_ARRAY
  59. #define DIFAT_ARRAY_SIZE 8
  60. BOOL _fDoingFixup;
  61. #ifdef LARGE_DOCFILE
  62. ULONG _cUnmarked;
  63. #else
  64. USHORT _cUnmarked;
  65. #endif
  66. SECT _sectUnmarked[DIFAT_ARRAY_SIZE];
  67. SECT _sectMarkTo[DIFAT_ARRAY_SIZE];
  68. SECT _sectFree[DIFAT_ARRAY_SIZE];
  69. #endif
  70. SCODE Resize(FSINDEX fsiSize);
  71. inline VOID SectToPair(
  72. SECT sect,
  73. FSINDEX *pipfs,
  74. FSOFFSET *pisect) const;
  75. SECT PairToSect(FSINDEX ipfs, FSOFFSET isect) const;
  76. };
  77. //+-------------------------------------------------------------------------
  78. //
  79. // Method: CDIFat::~CDIFat, public
  80. //
  81. // Synopsis: CDIFat destructor
  82. //
  83. // History: 11-May-92 PhilipLa Created.
  84. //
  85. //--------------------------------------------------------------------------
  86. inline CDIFat::~CDIFat()
  87. {
  88. msfDebugOut((DEB_ITRACE, "In CDIFat destructor\n"));
  89. msfDebugOut((DEB_ITRACE, "Out CDIFat destructor\n"));
  90. }
  91. //+-------------------------------------------------------------------------
  92. //
  93. // Method: CDIFat::InitCopy, public
  94. //
  95. // Synopsis: Init function for copying
  96. //
  97. // Arguments: [pfatOld] -- reference to CDIFat to be copied.
  98. //
  99. // Returns: S_OK if call completed OK.
  100. //
  101. // Algorithm: *Finish This*
  102. //
  103. // History: 11-May-92 PhilipLa Created.
  104. //
  105. // Notes:
  106. //
  107. //--------------------------------------------------------------------------
  108. inline void CDIFat::InitCopy(CDIFat *pfatOld)
  109. {
  110. msfDebugOut((DEB_ITRACE, "In CDIFat copy constructor\n"));
  111. _pmsParent = pfatOld->_pmsParent;
  112. _cfsTable = pfatOld->_cfsTable;
  113. _fv.InitCommon(pfatOld->_fv.GetSectBlock(), pfatOld->_fv.GetSectTable());
  114. _fv.InitCopy(&pfatOld->_fv);
  115. msfDebugOut((DEB_ITRACE, "Out CDIFat copy constructor\n"));
  116. }
  117. inline VOID CDIFat::SectToPair(FSINDEX sect, FSINDEX *pipfs, FSOFFSET *pisect) const
  118. {
  119. msfAssert(sect >= CSECTFAT);
  120. sect = sect - CSECTFAT;
  121. *pipfs = (FSINDEX)(sect / _fv.GetSectTable());
  122. *pisect = (FSOFFSET)(sect % _fv.GetSectTable());
  123. }
  124. inline SECT CDIFat::PairToSect(FSINDEX ipfs, FSOFFSET isect) const
  125. {
  126. return ipfs * _fv.GetSectTable() + isect + CSECTFAT;
  127. }
  128. inline void CDIFat::SetParent(CMStream *pms)
  129. {
  130. _pmsParent = P_TO_BP(CBasedMStreamPtr, pms);
  131. _fv.SetParent(pms);
  132. }
  133. #ifdef DIFAT_LOOKUP_ARRAY
  134. inline void CDIFat::CacheUnmarkedSect(SECT sectNew,
  135. SECT sectMark,
  136. SECT sectFree)
  137. {
  138. if (_cUnmarked < DIFAT_ARRAY_SIZE)
  139. {
  140. _sectUnmarked[_cUnmarked] = sectNew;
  141. _sectMarkTo[_cUnmarked] = sectMark;
  142. _sectFree[_cUnmarked] = sectFree;
  143. }
  144. _cUnmarked++;
  145. }
  146. #endif
  147. #endif //__DIFAT_HXX__