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.

125 lines
3.4 KiB

  1. // SymbolTable.h: interface for the CSymbolTable class.
  2. //
  3. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  4. // 1999. This computer program includes Confidential, Proprietary
  5. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  6. // use, disclosure, and/or reproduction is prohibited unless authorized
  7. // in writing. All Rights Reserved.
  8. //////////////////////////////////////////////////////////////////////
  9. #if !defined(SLBCCI_SYMBOLTABLE_H)
  10. #define SLBCCI_SYMBOLTABLE_H
  11. #include <memory> // for auto_ptr
  12. #include <string>
  13. #include <vector>
  14. #include <scuArrayP.h>
  15. #include "slbarch.h"
  16. namespace cci {
  17. class CSymbolTable
  18. {
  19. friend class CFreeBlock;
  20. public:
  21. CSymbolTable(iop::CSmartCard &rSmartCard,
  22. const std::string &rPath,
  23. unsigned short Offset);
  24. virtual ~CSymbolTable();
  25. std::string Find(SymbolID const &rsid);
  26. bool Find(std::string const &rsOrig,
  27. SymbolID *sid);
  28. SymbolID Add(std::string const &strNew, ShareMode mode=smShared);
  29. bool Remove(SymbolID const &rsid);
  30. void Replace(SymbolID const &rsid, std::string const &strUpd);
  31. unsigned short NumSymbols();
  32. unsigned short FirstFreeBlock();
  33. void FirstFreeBlock(unsigned short sFree);
  34. unsigned short TableSize();
  35. WORD Hash(std::string const &rstr);
  36. std::vector<std::string> CSymbolTable::EnumStrings();
  37. void Compress();
  38. void Reset();
  39. void DumpState();
  40. unsigned short FreeSpace();
  41. private:
  42. void
  43. ClearTableEntry(BYTE const &rsid);
  44. void
  45. UpdateTableEntry(BYTE const &rsid,
  46. WORD wNewHash,
  47. WORD wNewOffset,
  48. WORD wNewLength);
  49. BYTE RefCount(BYTE const &sidx);
  50. void GetSymbolTable();
  51. void SelectSymbolFile();
  52. void ReadSymbolFile(const WORD wOffset, const WORD wDataLength, BYTE* bDATA);
  53. void WriteSymbolFile(const WORD wOffset, const WORD wDataLength, const BYTE* bDATA);
  54. iop::CSmartCard &m_rSmartCard;
  55. unsigned short m_Offset;
  56. scu::AutoArrayPtr<std::string> m_aastrCachedStrings;
  57. scu::AutoArrayPtr<bool> m_aafCacheMask;
  58. scu::AutoArrayPtr<unsigned short> m_aasHashTable;
  59. scu::AutoArrayPtr<unsigned short> m_aasOffsetTable;
  60. scu::AutoArrayPtr<unsigned short> m_aasLengthTable;
  61. bool m_fSymbolTableLoaded;
  62. std::string m_Path;
  63. CArchivedValue<unsigned short> m_sMaxNumSymbols;
  64. CArchivedValue<unsigned short> m_sFirstFreeBlock;
  65. CArchivedValue<unsigned short> m_sTableSize;
  66. };
  67. class CFreeBlock
  68. {
  69. public:
  70. CFreeBlock(CSymbolTable *pSymTable, unsigned short sStartLocation);
  71. virtual ~CFreeBlock() {};
  72. std::auto_ptr<CFreeBlock>
  73. Next();
  74. void
  75. Update();
  76. unsigned short m_sStartLoc;
  77. unsigned short m_sBlockLength;
  78. unsigned short m_sNextBlock;
  79. private:
  80. CSymbolTable *m_pSymbolTable;
  81. };
  82. const unsigned short SymbNumSymbolLoc = 0; // Location of Number of symbols
  83. const unsigned short SymbFreeListLoc = 1; // Location of Free list
  84. const unsigned short SymbTableSizeLoc = 3; // Location of symbol table size
  85. const unsigned short SymbHashTableLoc = 5; // Location of hash table
  86. }
  87. #endif // !defined(SLBCCI_SYMBOLTABLE_H)