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.

181 lines
4.1 KiB

  1. #ifndef _STATICFILE_HXX_
  2. #define _STATICFILE_HXX_
  3. #include <stringau.hxx>
  4. class W3_STATIC_FILE_HANDLER : public W3_HANDLER
  5. {
  6. public:
  7. W3_STATIC_FILE_HANDLER( W3_CONTEXT * pW3Context )
  8. : W3_HANDLER( pW3Context ),
  9. m_pOpenFile( NULL ),
  10. m_pFooterDocument( NULL )
  11. {
  12. }
  13. ~W3_STATIC_FILE_HANDLER()
  14. {
  15. if ( m_pOpenFile != NULL )
  16. {
  17. m_pOpenFile->DereferenceCacheEntry();
  18. m_pOpenFile = NULL;
  19. }
  20. if ( m_pFooterDocument != NULL )
  21. {
  22. m_pFooterDocument->DereferenceCacheEntry();
  23. m_pFooterDocument = NULL;
  24. }
  25. }
  26. WCHAR *
  27. QueryName(
  28. VOID
  29. )
  30. {
  31. return L"StaticFileHandler";
  32. }
  33. CONTEXT_STATUS
  34. DoWork(
  35. VOID
  36. );
  37. static
  38. HRESULT
  39. Initialize(
  40. VOID
  41. );
  42. static
  43. VOID
  44. Terminate(
  45. VOID
  46. )
  47. {
  48. if ( sm_pstrRangeContentType != NULL )
  49. {
  50. delete sm_pstrRangeContentType;
  51. sm_pstrRangeContentType = NULL;
  52. }
  53. if ( sm_pstrRangeMidDelimiter != NULL )
  54. {
  55. delete sm_pstrRangeMidDelimiter;
  56. sm_pstrRangeMidDelimiter = NULL;
  57. }
  58. if ( sm_pstrRangeEndDelimiter != NULL )
  59. {
  60. delete sm_pstrRangeEndDelimiter;
  61. sm_pstrRangeEndDelimiter = NULL;
  62. }
  63. if ( sm_pachStaticFileHandlers != NULL )
  64. {
  65. delete sm_pachStaticFileHandlers;
  66. sm_pachStaticFileHandlers = NULL;
  67. }
  68. }
  69. BOOL
  70. QueryIsUlCacheable(
  71. VOID
  72. )
  73. {
  74. return TRUE;
  75. }
  76. HRESULT
  77. SetupUlCachedResponse(
  78. W3_CONTEXT * pW3Context
  79. );
  80. VOID *
  81. operator new(
  82. size_t size
  83. )
  84. {
  85. DBG_ASSERT( size == sizeof( W3_STATIC_FILE_HANDLER ) );
  86. DBG_ASSERT( sm_pachStaticFileHandlers != NULL );
  87. return sm_pachStaticFileHandlers->Alloc();
  88. }
  89. VOID
  90. operator delete(
  91. VOID * pStaticFileHandler
  92. )
  93. {
  94. DBG_ASSERT( pStaticFileHandler != NULL );
  95. DBG_ASSERT( sm_pachStaticFileHandlers != NULL );
  96. DBG_REQUIRE( sm_pachStaticFileHandlers->Free( pStaticFileHandler ) );
  97. }
  98. private:
  99. W3_FILE_INFO * m_pOpenFile;
  100. W3_FILE_INFO * m_pFooterDocument;
  101. STRA m_strFooterString;
  102. STRA m_strDirlistResponse;
  103. BUFFER_CHAIN m_RangeBufferChain;
  104. static STRA * sm_pstrRangeContentType;
  105. static STRA * sm_pstrRangeMidDelimiter;
  106. static STRA * sm_pstrRangeEndDelimiter;
  107. static ALLOC_CACHE_HANDLER* sm_pachStaticFileHandlers;
  108. HRESULT
  109. FileDoWork(
  110. W3_CONTEXT * pW3Context,
  111. W3_FILE_INFO * pFileInfo
  112. );
  113. HRESULT
  114. RangeDoWork(
  115. W3_CONTEXT * pW3Context,
  116. W3_FILE_INFO * pFileInfo,
  117. BOOL * pfHandled
  118. );
  119. HRESULT
  120. CacheValidationDoWork(
  121. W3_CONTEXT * pW3Context,
  122. W3_FILE_INFO * pFileInfo,
  123. BOOL * pfHandled
  124. );
  125. HRESULT
  126. DirectoryDoWork(
  127. W3_CONTEXT * pW3Context,
  128. BOOL * pfAsyncPending
  129. );
  130. HRESULT
  131. HandleDefaultLoad(
  132. W3_CONTEXT * pW3Context,
  133. BOOL * pfHandled,
  134. BOOL * pfAsyncPending
  135. );
  136. HRESULT
  137. HandleDirectoryListing(
  138. W3_CONTEXT * pW3Context,
  139. BOOL * pfHandled
  140. );
  141. HRESULT
  142. MapFileDoWork(
  143. W3_CONTEXT * pW3Context,
  144. W3_FILE_INFO * pFileInfo,
  145. BOOL * pfHandled
  146. );
  147. HRESULT SearchMapFile(LPCSTR pszFileContents,
  148. const DWORD cbFileSize,
  149. const int x,
  150. const int y,
  151. STRA *pstrTarget);
  152. };
  153. #endif