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.

153 lines
4.3 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. C449File(); // should be done using Create449Cookie()
  50. ~C449File(); // should be done using Release()
  51. HRESULT Init(TCHAR *szFile);
  52. public:
  53. // public constructor
  54. static HRESULT Create449File(TCHAR *szFile, C449File **ppFile);
  55. HRESULT Load();
  56. inline char *SzBuffer() { return m_szBuffer; }
  57. inline DWORD CbBuffer() { return m_cbBuffer; }
  58. inline void SetNeedLoad() { InterlockedExchange(&m_fNeedLoad, 1); }
  59. // IUnknown implementation
  60. STDMETHODIMP QueryInterface(REFIID, VOID**);
  61. STDMETHODIMP_(ULONG) AddRef(void);
  62. STDMETHODIMP_(ULONG) Release(void);
  63. // Cache on per-class basis
  64. ACACHE_INCLASS_DEFINITIONS()
  65. };
  66. /*===================================================================
  67. C449FileMgr class definition
  68. file manager keeps the hash table of files
  69. ===================================================================*/
  70. class C449FileMgr
  71. {
  72. private:
  73. CRITICAL_SECTION m_csLock;
  74. CHashTableMBStr m_ht449Files;
  75. inline void Lock() { EnterCriticalSection(&m_csLock); }
  76. inline void UnLock() { LeaveCriticalSection(&m_csLock); }
  77. public:
  78. C449FileMgr();
  79. ~C449FileMgr();
  80. HRESULT Init();
  81. // find or create a new one
  82. HRESULT GetFile(TCHAR *szFile, C449File **ppFile);
  83. // change notification
  84. HRESULT Flush(TCHAR *szFile);
  85. HRESULT FlushAll();
  86. };
  87. /*===================================================================
  88. C449Cookie class definition
  89. cookie is a cookie -- file pair
  90. ===================================================================*/
  91. class C449Cookie : public IUnknown
  92. {
  93. private:
  94. LONG m_cRefs; // ref count
  95. char *m_szName; // cookie name to check
  96. DWORD m_cbName; // cookie name length
  97. C449File *m_pFile; // related file
  98. C449Cookie(); // should be done using Create449Cookie()
  99. ~C449Cookie(); // should be done using Release()
  100. HRESULT Init(char *szName, C449File *pFile);
  101. public:
  102. // public constructor
  103. static HRESULT Create449Cookie(char *szName, C449File *pFile, C449Cookie **pp449);
  104. inline char *SzCookie() { return m_szName; }
  105. inline DWORD CbCookie() { return m_cbName; }
  106. inline HRESULT LoadFile() { return m_pFile ? m_pFile->Load() : E_FAIL; }
  107. inline char *SzBuffer() { return m_pFile ? m_pFile->SzBuffer() : NULL; }
  108. inline DWORD CbBuffer() { return m_pFile ? m_pFile->CbBuffer() : 0; }
  109. // IUnknown implementation
  110. STDMETHODIMP QueryInterface(REFIID, VOID**);
  111. STDMETHODIMP_(ULONG) AddRef(void);
  112. STDMETHODIMP_(ULONG) Release(void);
  113. // Cache on per-class basis
  114. ACACHE_INCLASS_DEFINITIONS()
  115. };
  116. #endif // IE449_H