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.

106 lines
2.7 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. #include <mapper.hxx>
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CSourceMapper::Advance
  21. //
  22. // Synopsis: Advance the mapper after processing ccDelta characters
  23. //
  24. // History: 30-Sep-94 BartoszM Created.
  25. //
  26. //----------------------------------------------------------------------------
  27. void CSourceMapper::Advance ( ULONG ccProcessed )
  28. {
  29. _offInChunk += ccProcessed;
  30. if (_offSplit != 0)
  31. {
  32. // split buffer situation (two current chunks)
  33. if (ccProcessed >= _offSplit)
  34. {
  35. // got rid of leftover chunk
  36. _offInChunk = ccProcessed - _offSplit;
  37. _offSplit = 0;
  38. _idChunk = _idNewChunk;
  39. }
  40. else
  41. _offSplit -= ccProcessed;
  42. }
  43. }
  44. void CSourceMapper::NewChunk ( ULONG idChunk, ULONG ccBegin )
  45. {
  46. if (ccBegin != 0)
  47. {
  48. _offSplit = ccBegin;
  49. _idNewChunk = idChunk;
  50. }
  51. else
  52. {
  53. _offSplit = 0;
  54. _idChunk = idChunk;
  55. _offInChunk = 0;
  56. }
  57. _ccLen = 0;
  58. }
  59. void CSourceMapper::NewDerivedChunk ( ULONG idChunkSource, ULONG ccBeginSource, ULONG ccLen )
  60. {
  61. _idChunk = idChunkSource;
  62. _offInChunk = ccBeginSource;
  63. _offSplit = 0;
  64. _ccLen = ccLen;
  65. }
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Member: CSourceMapper::GetSrcRegion
  69. //
  70. // Synopsis: Returns source filter region for current position
  71. //
  72. // History: 23-Sep-94 BartoszM Created.
  73. //
  74. //----------------------------------------------------------------------------
  75. void CSourceMapper::GetSrcRegion ( FILTERREGION& region, ULONG len, ULONG ccOffsetInBuf )
  76. {
  77. if (_offSplit == 0 || ccOffsetInBuf < _offSplit)
  78. {
  79. region.idChunk = _idChunk;
  80. if (_ccLen == 0) // direct mapping
  81. {
  82. region.cwcStart = _offInChunk + ccOffsetInBuf;
  83. region.cwcExtent = len;
  84. }
  85. else // map to whole region
  86. {
  87. region.cwcStart = _offInChunk;
  88. region.cwcExtent = _ccLen;
  89. }
  90. }
  91. else
  92. {
  93. region.idChunk = _idNewChunk;
  94. region.cwcStart = ccOffsetInBuf - _offSplit;
  95. region.cwcExtent = len;
  96. }
  97. }