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.

160 lines
4.7 KiB

  1. /*===================================================================
  2. Microsoft IIS 5.0 (ASP)
  3. Microsoft Confidential.
  4. Copyright 1998 Microsoft Corporation. All Rights Reserved.
  5. Component: 449 negotiations w/IE
  6. File: ie449.h
  7. Owner: DmitryR
  8. This file contains the definitons for the 449 negotiations w/IE
  9. ===================================================================*/
  10. #ifndef IE449_H
  11. #define IE449_H
  12. #include "hashing.h"
  13. #include "aspdmon.h"
  14. #include "memcls.h"
  15. // forward declr
  16. class CHitObj;
  17. class C449Cookie;
  18. class C449File;
  19. /*===================================================================
  20. The API
  21. ===================================================================*/
  22. // init/uninit on dll level
  23. HRESULT Init449();
  24. HRESULT UnInit449();
  25. // create a new cookie
  26. HRESULT Create449Cookie(char *szName, TCHAR *szFile, C449Cookie **pp449);
  27. // do the work
  28. HRESULT Do449Processing
  29. (
  30. CHitObj *pHitObj,
  31. C449Cookie **rgpCookies,
  32. DWORD cCookies
  33. );
  34. // change notification processing
  35. HRESULT Do449ChangeNotification(TCHAR *szFile = NULL);
  36. /*===================================================================
  37. C449File class definition
  38. files are hashed
  39. ===================================================================*/
  40. class C449File : public IUnknown, public CLinkElem
  41. {
  42. private:
  43. LONG m_cRefs; // ref count
  44. LONG m_fNeedLoad; // flag when need to reload (Interlocked)
  45. TCHAR *m_szFile; // file name with script
  46. char *m_szBuffer; // file contents
  47. DWORD m_cbBuffer; // file contents length
  48. CDirMonitorEntry *m_pDME; // for change notification support
  49. HANDLE m_hFileReadyForUse; // is the File ready for use by other threads
  50. HRESULT m_hrLoadResult; // record result of load here?
  51. C449File(); // should be done using Create449Cookie()
  52. ~C449File(); // should be done using Release()
  53. HRESULT Init(TCHAR *szFile);
  54. public:
  55. // public constructor
  56. static HRESULT Create449File(TCHAR *szFile, C449File **ppFile);
  57. HRESULT Load();
  58. inline char *SzBuffer() { return m_szBuffer; }
  59. inline DWORD CbBuffer() { return m_cbBuffer; }
  60. inline void SetNeedLoad()
  61. {
  62. ResetEvent (m_hFileReadyForUse);
  63. m_hrLoadResult = E_FAIL;
  64. InterlockedExchange(&m_fNeedLoad, 1);
  65. }
  66. // IUnknown implementation
  67. STDMETHODIMP QueryInterface(REFIID, VOID**);
  68. STDMETHODIMP_(ULONG) AddRef(void);
  69. STDMETHODIMP_(ULONG) Release(void);
  70. // Cache on per-class basis
  71. ACACHE_INCLASS_DEFINITIONS()
  72. };
  73. /*===================================================================
  74. C449FileMgr class definition
  75. file manager keeps the hash table of files
  76. ===================================================================*/
  77. class C449FileMgr
  78. {
  79. private:
  80. CRITICAL_SECTION m_csLock;
  81. CHashTableMBStr m_ht449Files;
  82. inline void Lock() { EnterCriticalSection(&m_csLock); }
  83. inline void UnLock() { LeaveCriticalSection(&m_csLock); }
  84. public:
  85. C449FileMgr();
  86. ~C449FileMgr();
  87. HRESULT Init();
  88. // find or create a new one
  89. HRESULT GetFile(TCHAR *szFile, C449File **ppFile);
  90. // change notification
  91. HRESULT Flush(TCHAR *szFile);
  92. HRESULT FlushAll();
  93. };
  94. /*===================================================================
  95. C449Cookie class definition
  96. cookie is a cookie -- file pair
  97. ===================================================================*/
  98. class C449Cookie : public IUnknown
  99. {
  100. private:
  101. LONG m_cRefs; // ref count
  102. char *m_szName; // cookie name to check
  103. DWORD m_cbName; // cookie name length
  104. C449File *m_pFile; // related file
  105. C449Cookie(); // should be done using Create449Cookie()
  106. ~C449Cookie(); // should be done using Release()
  107. HRESULT Init(char *szName, C449File *pFile);
  108. public:
  109. // public constructor
  110. static HRESULT Create449Cookie(char *szName, C449File *pFile, C449Cookie **pp449);
  111. inline char *SzCookie() { return m_szName; }
  112. inline DWORD CbCookie() { return m_cbName; }
  113. inline HRESULT LoadFile() { return m_pFile ? m_pFile->Load() : E_FAIL; }
  114. inline char *SzBuffer() { return m_pFile ? m_pFile->SzBuffer() : NULL; }
  115. inline DWORD CbBuffer() { return m_pFile ? m_pFile->CbBuffer() : 0; }
  116. // IUnknown implementation
  117. STDMETHODIMP QueryInterface(REFIID, VOID**);
  118. STDMETHODIMP_(ULONG) AddRef(void);
  119. STDMETHODIMP_(ULONG) Release(void);
  120. // Cache on per-class basis
  121. ACACHE_INCLASS_DEFINITIONS()
  122. };
  123. #endif // IE449_H