Source code of Windows XP (NT5)
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.

103 lines
2.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: MAPPER.CXX
  7. //
  8. // Contents: Search Key Repository
  9. //
  10. // Classes: CSourceMapper
  11. //
  12. // History: 23-Sep-94 BartoszM Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. //+---------------------------------------------------------------------------
  18. //
  19. // Member: CSourceMapper::Advance
  20. //
  21. // Synopsis: Advance the mapper after processing ccDelta characters
  22. //
  23. // History: 30-Sep-94 BartoszM Created.
  24. //
  25. //----------------------------------------------------------------------------
  26. void CSourceMapper::Advance ( ULONG ccProcessed )
  27. {
  28. _offInChunk += ccProcessed;
  29. if (_offSplit != 0)
  30. {
  31. // split buffer situation (two current chunks)
  32. if (ccProcessed >= _offSplit)
  33. {
  34. // got rid of leftover chunk
  35. _offInChunk = ccProcessed - _offSplit;
  36. _offSplit = 0;
  37. _idChunk = _idNewChunk;
  38. }
  39. else
  40. _offSplit -= ccProcessed;
  41. }
  42. }
  43. void CSourceMapper::NewChunk ( ULONG idChunk, ULONG ccBegin )
  44. {
  45. if (ccBegin != 0)
  46. {
  47. _offSplit = ccBegin;
  48. _idNewChunk = idChunk;
  49. }
  50. else
  51. {
  52. _offSplit = 0;
  53. _idChunk = idChunk;
  54. _offInChunk = 0;
  55. }
  56. _ccLen = 0;
  57. }
  58. void CSourceMapper::NewDerivedChunk ( ULONG idChunkSource, ULONG ccBeginSource, ULONG ccLen )
  59. {
  60. _idChunk = idChunkSource;
  61. _offInChunk = ccBeginSource;
  62. _offSplit = 0;
  63. _ccLen = ccLen;
  64. }
  65. //+---------------------------------------------------------------------------
  66. //
  67. // Member: CSourceMapper::GetSrcRegion
  68. //
  69. // Synopsis: Returns source filter region for current position
  70. //
  71. // History: 23-Sep-94 BartoszM Created.
  72. //
  73. //----------------------------------------------------------------------------
  74. void CSourceMapper::GetSrcRegion ( FILTERREGION& region, ULONG len, ULONG ccOffsetInBuf )
  75. {
  76. if (_offSplit == 0 || ccOffsetInBuf < _offSplit)
  77. {
  78. region.idChunk = _idChunk;
  79. if (_ccLen == 0) // direct mapping
  80. {
  81. region.cwcStart = _offInChunk + ccOffsetInBuf;
  82. region.cwcExtent = len;
  83. }
  84. else // map to whole region
  85. {
  86. region.cwcStart = _offInChunk;
  87. region.cwcExtent = _ccLen;
  88. }
  89. }
  90. else
  91. {
  92. region.idChunk = _idNewChunk;
  93. region.cwcStart = ccOffsetInBuf - _offSplit;
  94. region.cwcExtent = len;
  95. }
  96. }