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.

132 lines
2.5 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. DWORD _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 * pEntry,
  60. int nIncr
  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. HRESULT hr;
  83. retCode = sm_pRequestHash->FindKey( pszName,
  84. &pRecord );
  85. if ( retCode == LK_SUCCESS )
  86. {
  87. DBG_ASSERT( pRecord != NULL );
  88. return pRecord->_ulHeaderIndex;
  89. }
  90. else
  91. {
  92. return UNKNOWN_INDEX;
  93. }
  94. }
  95. static
  96. CHAR *
  97. GetString(
  98. ULONG ulIndex,
  99. DWORD * pcchLength
  100. )
  101. {
  102. if ( ulIndex < HttpHeaderRequestMaximum )
  103. {
  104. *pcchLength = sm_rgHeaders[ ulIndex ]._cchName;
  105. return sm_rgHeaders[ ulIndex ]._pszName;
  106. }
  107. return NULL;
  108. }
  109. private:
  110. static REQUEST_HEADER_HASH *sm_pRequestHash;
  111. static HEADER_RECORD sm_rgHeaders[];
  112. };
  113. #endif