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.

104 lines
2.8 KiB

  1. /*-----------------------------------------------------------------------------
  2. Microsoft Denali
  3. Microsoft Confidential
  4. Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. Component: File/Application mapping
  6. File: CFileApp.h
  7. Owner: CGrant
  8. File/Application mapping definition
  9. -----------------------------------------------------------------------------*/
  10. #ifndef _CFILEAPP_H
  11. #define _CFILEAPP_H
  12. // Includes -------------------------------------------------------------------
  13. #include "applmgr.h"
  14. #include "hashing.h"
  15. #include "idhash.h"
  16. #include "memcls.h"
  17. #define NUM_FILEAPP_HASHING_BUCKETS 17
  18. /*****************************************************************************
  19. Class: CFileApplicationMap
  20. Synopsis: Maintains a database relating files to the applications that
  21. must be shut down if the file changes. The key for the hash table
  22. is the full file name
  23. */
  24. class CFileApplicationMap : public CHashTable
  25. {
  26. // Flags
  27. DWORD m_fInited : 1; // Are we initialized?
  28. DWORD m_fHashTableInited : 1; // Need to UnInit hash table?
  29. DWORD m_fCriticalSectionInited : 1; // Need to delete CS?
  30. // Critical section for locking
  31. CRITICAL_SECTION m_csLock;
  32. public:
  33. CFileApplicationMap();
  34. ~CFileApplicationMap();
  35. void Lock();
  36. void UnLock();
  37. HRESULT Init();
  38. HRESULT UnInit();
  39. HRESULT AddFileApplication(const TCHAR *pszFileName, CAppln *pAppln);
  40. BOOL ShutdownApplications(const TCHAR *pszFile);
  41. };
  42. inline void CFileApplicationMap::Lock()
  43. {
  44. Assert(m_fInited);
  45. EnterCriticalSection(&m_csLock);
  46. }
  47. inline void CFileApplicationMap::UnLock()
  48. {
  49. Assert(m_fInited);
  50. LeaveCriticalSection( &m_csLock );
  51. }
  52. /*****************************************************************************
  53. Class: CFileApplnList
  54. Synopsis: Maintains a list of applications that
  55. must be shut down if a file changes
  56. */
  57. class CFileApplnList : public CLinkElem
  58. {
  59. friend class CFileApplicationMap;
  60. TCHAR* m_pszFilename;
  61. CPtrArray m_rgpvApplications; // the list of applications
  62. BOOL m_fInited; // flag indicating initialization
  63. public:
  64. CFileApplnList();
  65. ~CFileApplnList();
  66. HRESULT Init(const TCHAR* pszFilename);
  67. HRESULT UnInit();
  68. HRESULT AddApplication(void *pApplication);
  69. HRESULT RemoveApplication(void *pApplication);
  70. VOID GetShutdownApplications(CPtrArray *prgpapplnRestartList);
  71. // Cache on per-class basis
  72. ACACHE_INCLASS_DEFINITIONS()
  73. };
  74. /*===================================================================
  75. Globals
  76. ===================================================================*/
  77. extern CFileApplicationMap g_FileAppMap;
  78. #endif // _CFILEAPP_H