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.

118 lines
2.3 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 *,
  46. int
  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. retCode = sm_pMethodHash->FindKey( pszName,
  69. &pRecord );
  70. if ( retCode == LK_SUCCESS )
  71. {
  72. DBG_ASSERT( pRecord != NULL );
  73. return pRecord->_ulHeaderIndex;
  74. }
  75. else
  76. {
  77. return HttpVerbUnknown;
  78. }
  79. }
  80. static
  81. CHAR *
  82. GetString(
  83. ULONG ulIndex,
  84. USHORT * pcchLength
  85. )
  86. {
  87. for (DWORD i = 0; sm_rgMethods[i]._pszName != NULL; i++)
  88. {
  89. if (ulIndex == sm_rgMethods[i]._ulHeaderIndex)
  90. {
  91. *pcchLength = sm_rgMethods[i]._cchName;
  92. return sm_rgMethods[i]._pszName;
  93. }
  94. }
  95. return NULL;
  96. }
  97. private:
  98. static METHOD_HASH *sm_pMethodHash;
  99. static HEADER_RECORD sm_rgMethods[];
  100. METHOD_HASH(const METHOD_HASH &);
  101. void operator=(const METHOD_HASH &);
  102. };
  103. #endif