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.

134 lines
2.7 KiB

  1. #ifndef _REQUEST_HEADERHASH_HXX_
  2. #define _REQUEST_HEADERHASH_HXX_
  3. //
  4. // Helper class for String->Index hash
  5. //
  6. struct HEADER_RECORD
  7. {
  8. ULONG _ulHeaderIndex;
  9. CHAR * _pszName;
  10. USHORT _cchName;
  11. };
  12. #define HEADER(x) x, sizeof(x) - sizeof(CHAR)
  13. //
  14. // *_HEADER_HASH maps strings to UlHeader* values
  15. //
  16. #define UNKNOWN_INDEX (0xFFFFFFFF)
  17. class REQUEST_HEADER_HASH
  18. : public CTypedHashTable< REQUEST_HEADER_HASH,
  19. HEADER_RECORD,
  20. CHAR * >
  21. {
  22. public:
  23. REQUEST_HEADER_HASH()
  24. : CTypedHashTable< REQUEST_HEADER_HASH,
  25. HEADER_RECORD,
  26. CHAR * >
  27. ("REQUEST_HEADER_HASH")
  28. {
  29. }
  30. static
  31. CHAR *
  32. ExtractKey(
  33. const HEADER_RECORD * pRecord
  34. )
  35. {
  36. DBG_ASSERT( pRecord != NULL );
  37. return pRecord->_pszName;
  38. }
  39. static
  40. DWORD
  41. CalcKeyHash(
  42. CHAR * pszKey
  43. )
  44. {
  45. return HashStringNoCase( pszKey );
  46. }
  47. static
  48. bool
  49. EqualKeys(
  50. CHAR * pszKey1,
  51. CHAR * pszKey2
  52. )
  53. {
  54. return _stricmp( pszKey1, pszKey2 ) == 0;
  55. }
  56. static
  57. void
  58. AddRefRecord(
  59. HEADER_RECORD *,
  60. int
  61. )
  62. {
  63. }
  64. static
  65. HRESULT
  66. Initialize(
  67. VOID
  68. );
  69. static
  70. VOID
  71. Terminate(
  72. VOID
  73. );
  74. static
  75. ULONG
  76. GetIndex(
  77. CHAR * pszName
  78. )
  79. {
  80. HEADER_RECORD * pRecord = NULL;
  81. LK_RETCODE retCode;
  82. retCode = sm_pRequestHash->FindKey( pszName,
  83. &pRecord );
  84. if ( retCode == LK_SUCCESS )
  85. {
  86. DBG_ASSERT( pRecord != NULL );
  87. return pRecord->_ulHeaderIndex;
  88. }
  89. else
  90. {
  91. return UNKNOWN_INDEX;
  92. }
  93. }
  94. static
  95. CHAR *
  96. GetString(
  97. ULONG ulIndex,
  98. DWORD * pcchLength
  99. )
  100. {
  101. if ( ulIndex < HttpHeaderRequestMaximum )
  102. {
  103. *pcchLength = sm_rgHeaders[ ulIndex ]._cchName;
  104. return sm_rgHeaders[ ulIndex ]._pszName;
  105. }
  106. return NULL;
  107. }
  108. private:
  109. static REQUEST_HEADER_HASH *sm_pRequestHash;
  110. static HEADER_RECORD sm_rgHeaders[];
  111. REQUEST_HEADER_HASH(const REQUEST_HEADER_HASH &);
  112. void operator=(const REQUEST_HEADER_HASH &);
  113. };
  114. #endif