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.

116 lines
2.2 KiB

  1. #ifndef _METHODHASH_HXX_
  2. #define _METHODHASH_HXX_
  3. class METHOD_HASH
  4. : public CTypedHashTable< METHOD_HASH,
  5. HEADER_RECORD,
  6. CHAR * >
  7. {
  8. public:
  9. METHOD_HASH()
  10. : CTypedHashTable< METHOD_HASH,
  11. HEADER_RECORD,
  12. CHAR * >
  13. ("METHOD_HASH")
  14. {
  15. }
  16. static
  17. CHAR *
  18. ExtractKey(
  19. const HEADER_RECORD * pRecord
  20. )
  21. {
  22. DBG_ASSERT( pRecord != NULL );
  23. return pRecord->_pszName;
  24. }
  25. static
  26. DWORD
  27. CalcKeyHash(
  28. CHAR * pszKey
  29. )
  30. {
  31. return Hash( pszKey );
  32. }
  33. static
  34. bool
  35. EqualKeys(
  36. CHAR * pszKey1,
  37. CHAR * pszKey2
  38. )
  39. {
  40. return strcmp( pszKey1, pszKey2 ) == 0;
  41. }
  42. static
  43. void
  44. AddRefRecord(
  45. HEADER_RECORD * pEntry,
  46. int nIncr
  47. )
  48. {
  49. }
  50. static
  51. HRESULT
  52. Initialize(
  53. VOID
  54. );
  55. static
  56. VOID
  57. Terminate(
  58. VOID
  59. );
  60. static
  61. ULONG
  62. GetIndex(
  63. CHAR * pszName
  64. )
  65. {
  66. HEADER_RECORD * pRecord = NULL;
  67. LK_RETCODE retCode;
  68. HRESULT hr;
  69. retCode = sm_pMethodHash->FindKey( pszName,
  70. &pRecord );
  71. if ( retCode == LK_SUCCESS )
  72. {
  73. DBG_ASSERT( pRecord != NULL );
  74. return pRecord->_ulHeaderIndex;
  75. }
  76. else
  77. {
  78. return HttpVerbUnknown;
  79. }
  80. }
  81. static
  82. CHAR *
  83. GetString(
  84. ULONG ulIndex,
  85. USHORT * pcchLength
  86. )
  87. {
  88. for (DWORD i = 0; sm_rgMethods[i]._pszName != NULL; i++)
  89. {
  90. if (ulIndex == sm_rgMethods[i]._ulHeaderIndex)
  91. {
  92. *pcchLength = sm_rgMethods[i]._cchName;
  93. return sm_rgMethods[i]._pszName;
  94. }
  95. }
  96. return NULL;
  97. }
  98. private:
  99. static METHOD_HASH *sm_pMethodHash;
  100. static HEADER_RECORD sm_rgMethods[];
  101. };
  102. #endif