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.

132 lines
2.8 KiB

  1. #include "stdinc.h"
  2. #include "lhport.h"
  3. #include "positionindependentstringpool.h"
  4. #include "numberof.h"
  5. int __stdcall CPositionIndependentStringPool::Compare(const BYTE * p, const BYTE * q)
  6. {
  7. return wcscmp(reinterpret_cast<PCWSTR>(p), reinterpret_cast<PCWSTR>(q));
  8. }
  9. int __stdcall CPositionIndependentStringPool::Comparei(const BYTE * p, const BYTE * q)
  10. {
  11. return _wcsicmp(reinterpret_cast<PCWSTR>(p), reinterpret_cast<PCWSTR>(q));
  12. }
  13. int __stdcall CPositionIndependentStringPool::Equal(const BYTE * p, const BYTE * q)
  14. {
  15. return Compare(p, q) == 0;
  16. }
  17. int __stdcall CPositionIndependentStringPool::Equali(const BYTE * p, const BYTE * q)
  18. {
  19. return Comparei(p, q) == 0;
  20. }
  21. ULONG __stdcall CPositionIndependentStringPool::Hash(const BYTE * p)
  22. {
  23. PCWSTR q = reinterpret_cast<PCWSTR>(p);
  24. ULONG Hash;
  25. if (q[0] == 0)
  26. {
  27. return 0;
  28. }
  29. Hash = (static_cast<ULONG>(q[0]) << 16) | q[1];
  30. return Hash;
  31. }
  32. ULONG ToUpper(ULONG ch)
  33. {
  34. if (ch >= 'a' && ch <= 'z')
  35. return ch - 'a' + 'A';
  36. return ch;
  37. }
  38. ULONG ToLower(ULONG ch)
  39. {
  40. if (ch >= 'A' && ch <= 'Z')
  41. return ch - 'A' + 'a';
  42. return ch;
  43. }
  44. ULONG __stdcall CPositionIndependentStringPool::Hashi(const BYTE * p)
  45. {
  46. PCWSTR q = reinterpret_cast<PCWSTR>(p);
  47. ULONG Hash;
  48. if (q[0] == 0)
  49. {
  50. return 0;
  51. }
  52. Hash = (static_cast<ULONG>(ToLower(q[0])) << 16) | ToLower(q[1]);
  53. return Hash;
  54. }
  55. CPositionIndependentStringPool::CPositionIndependentStringPool()
  56. {
  57. const static CHashTableInit inits[2] =
  58. {
  59. { 17, Comparei, Hashi, Equali },
  60. { 17, Compare, Hash, Equal },
  61. };
  62. m_HashTable.ThrAddHashTables(NUMBER_OF(inits), inits);
  63. }
  64. BOOL
  65. CPositionIndependentStringPool::IsStringPresent(
  66. PCWSTR Key,
  67. ECaseSensitivity CaseSensitivity,
  68. CAddHint * AddHint
  69. )
  70. {
  71. CAddHint LocalAddHint;
  72. if (AddHint == NULL)
  73. AddHint = &LocalAddHint;
  74. AddHint->m_Accessors[0].Init(&m_HashTable, 0);
  75. AddHint->m_Accessors[1].Init(&m_HashTable, 1);
  76. return AddHint->m_Accessors[CaseSensitivityToInteger(CaseSensitivity)].IsKeyPresent(reinterpret_cast<const BYTE*>(Key));
  77. }
  78. ULONG
  79. CPositionIndependentStringPool::ThrAddIfNotPresent(PCWSTR, ECaseSensitivity eCaseSensitive)
  80. {
  81. return 0;
  82. }
  83. ULONG
  84. CPositionIndependentStringPool::ThrAdd(CAddHint & )
  85. {
  86. return 0;
  87. }
  88. PCWSTR
  89. CPositionIndependentStringPool::ThrGetStringAtIndex(ULONG)
  90. {
  91. return 0;
  92. }
  93. PCWSTR
  94. CPositionIndependentStringPool::ThrGetStringAtOffset(ULONG)
  95. {
  96. return 0;
  97. }
  98. ULONG
  99. CPositionIndependentStringPool::GetCount()
  100. {
  101. return 0;
  102. }
  103. BOOL
  104. CPositionIndependentStringPool::ThrPutToDisk(HANDLE FileHandle)
  105. {
  106. return 0;
  107. }
  108. BOOL
  109. CPositionIndependentStringPool::ThrGetFromDisk(HANDLE FileHandle, ULONGLONG Offset)
  110. {
  111. return 0;
  112. }