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.

92 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C M U T I L . H
  7. //
  8. // Contents: Connection manager.
  9. //
  10. // Notes:
  11. //
  12. // Author: omiller 1 Jun 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include "nmbase.h"
  17. #include <rasapip.h>
  18. #include <map>
  19. #include "nceh.h"
  20. struct CMEntry
  21. {
  22. CMEntry() throw() {}
  23. CMEntry(const CMEntry & ref) throw()
  24. {
  25. Set(ref.m_guid,ref.m_szEntryName,ref.m_ncs);
  26. }
  27. CMEntry(const GUID & guid,const WCHAR * szEntryName, const NETCON_STATUS ncs) throw()
  28. {
  29. Set(guid,szEntryName,ncs);
  30. }
  31. CMEntry & operator=(const CMEntry & ref) throw()
  32. {
  33. if(&ref != this)
  34. {
  35. Set(ref.m_guid, ref.m_szEntryName, ref.m_ncs);
  36. }
  37. return *this;
  38. }
  39. CMEntry & operator=(const CMEntry * ref) throw()
  40. {
  41. if(ref != this)
  42. {
  43. Set(ref->m_guid, ref->m_szEntryName, ref->m_ncs);
  44. }
  45. return *this;
  46. }
  47. void Set(const GUID & guid, const WCHAR * sz, const NETCON_STATUS ncs) throw()
  48. {
  49. ZeroMemory(m_szEntryName, sizeof(m_szEntryName));
  50. lstrcpyn(m_szEntryName, sz, NETCON_MAX_NAME_LEN);
  51. m_guid = guid;
  52. m_ncs = ncs;
  53. }
  54. WCHAR m_szEntryName[NETCON_MAX_NAME_LEN + 1];
  55. GUID m_guid;
  56. NETCON_STATUS m_ncs;
  57. };
  58. class CCMUtil
  59. {
  60. public:
  61. ~CCMUtil() throw();
  62. static CCMUtil & Instance() throw() { return s_instance; }
  63. HRESULT HrGetEntry(const GUID & guid, CMEntry & cm);
  64. HRESULT HrGetEntry(const WCHAR * szEntryName, CMEntry & cm);
  65. void SetEntry(const GUID & guid, const WCHAR * szEntryName, const NETCON_STATUS ncs) throw (std::bad_alloc);
  66. void RemoveEntry(const GUID & guid) throw();
  67. private:
  68. static CCMUtil s_instance;
  69. CRITICAL_SECTION m_CriticalSection;
  70. typedef vector<CMEntry> CMEntryTable;
  71. CMEntryTable m_Table;
  72. CMEntryTable::iterator GetIteratorFromGuid(const GUID & guid);
  73. CCMUtil() throw(SE_Exception);
  74. CCMUtil(const CCMUtil &) throw(); // Make this private to be sure we don't call the copy constructor
  75. };