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.

141 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. headerhash.cxx
  5. Abstract:
  6. Header hash goo
  7. Author:
  8. Bilal Alam (balam) 20-Feb-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. METHOD_HASH *METHOD_HASH::sm_pMethodHash;
  16. HEADER_RECORD METHOD_HASH::sm_rgMethods[] =
  17. {
  18. { HttpVerbOPTIONS, HEADER("OPTIONS") },
  19. { HttpVerbGET, HEADER("GET") },
  20. { HttpVerbHEAD, HEADER("HEAD") },
  21. { HttpVerbPOST, HEADER("POST") },
  22. { HttpVerbPUT, HEADER("PUT") },
  23. { HttpVerbDELETE, HEADER("DELETE") },
  24. { HttpVerbTRACE, HEADER("TRACE") },
  25. { HttpVerbCONNECT, HEADER("CONNECT") },
  26. { HttpVerbTRACK, HEADER("TRACK") },
  27. { HttpVerbMOVE, HEADER("MOVE") },
  28. { HttpVerbCOPY, HEADER("COPY") },
  29. { HttpVerbPROPFIND, HEADER("PROPFIND") },
  30. { HttpVerbPROPPATCH, HEADER("PROPPATCH") },
  31. { HttpVerbMKCOL, HEADER("MKCOL") },
  32. { HttpVerbLOCK, HEADER("LOCK") },
  33. { HttpVerbUNLOCK, HEADER("UNLOCK") },
  34. { HttpVerbSEARCH, HEADER("SEARCH") },
  35. { HttpVerbUnknown, NULL }
  36. };
  37. //static
  38. HRESULT
  39. METHOD_HASH::Initialize(
  40. VOID
  41. )
  42. /*++
  43. Routine Description:
  44. Initialize global header hash table
  45. Arguments:
  46. None
  47. Return Value:
  48. HRESULT
  49. --*/
  50. {
  51. HEADER_RECORD * pRecord;
  52. LK_RETCODE lkrc = LK_SUCCESS;
  53. DWORD dwNumRecords;
  54. //
  55. // Add header index/name to hash table
  56. //
  57. sm_pMethodHash = new METHOD_HASH();
  58. if ( sm_pMethodHash == NULL )
  59. {
  60. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  61. }
  62. //
  63. // Add every string->routine mapping
  64. //
  65. dwNumRecords = sizeof( sm_rgMethods ) / sizeof( HEADER_RECORD ) - 1;
  66. for ( DWORD i = 0; i < dwNumRecords; i++ )
  67. {
  68. pRecord = &(sm_rgMethods[ i ]);
  69. lkrc = sm_pMethodHash->InsertRecord( pRecord );
  70. if ( lkrc != LK_SUCCESS )
  71. {
  72. break;
  73. }
  74. }
  75. //
  76. // If any insert failed, then fail initialization
  77. //
  78. if ( lkrc != LK_SUCCESS )
  79. {
  80. delete sm_pMethodHash;
  81. sm_pMethodHash = NULL;
  82. return HRESULT_FROM_WIN32( lkrc ); // BUGBUG
  83. }
  84. else
  85. {
  86. return NO_ERROR;
  87. }
  88. }
  89. //static
  90. VOID
  91. METHOD_HASH::Terminate(
  92. VOID
  93. )
  94. /*++
  95. Routine Description:
  96. Global cleanup of header hash table
  97. Arguments:
  98. None
  99. Return Value:
  100. None
  101. --*/
  102. {
  103. if ( sm_pMethodHash != NULL )
  104. {
  105. delete sm_pMethodHash;
  106. sm_pMethodHash = NULL;
  107. }
  108. }