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.

92 lines
2.0 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 <stlmap.h>
  19. struct CMEntry
  20. {
  21. CMEntry() {}
  22. CMEntry(const CMEntry & ref)
  23. {
  24. Set(ref.m_guid,ref.m_szEntryName,ref.m_ncs);
  25. }
  26. CMEntry(const GUID & guid,const WCHAR * szEntryName, const NETCON_STATUS ncs)
  27. {
  28. Set(guid,szEntryName,ncs);
  29. }
  30. CMEntry & operator=(const CMEntry & ref)
  31. {
  32. if(&ref != this)
  33. {
  34. Set(ref.m_guid, ref.m_szEntryName, ref.m_ncs);
  35. }
  36. return *this;
  37. }
  38. CMEntry & operator=(const CMEntry * ref)
  39. {
  40. if(ref != this)
  41. {
  42. Set(ref->m_guid, ref->m_szEntryName, ref->m_ncs);
  43. }
  44. return *this;
  45. }
  46. void Set(const GUID & guid, const WCHAR * sz, const NETCON_STATUS ncs)
  47. {
  48. ZeroMemory(m_szEntryName, sizeof(m_szEntryName));
  49. lstrcpyn(m_szEntryName, sz, RASAPIP_MAX_ENTRY_NAME);
  50. m_guid = guid;
  51. m_ncs = ncs;
  52. }
  53. WCHAR m_szEntryName[RASAPIP_MAX_ENTRY_NAME + 1];
  54. GUID m_guid;
  55. NETCON_STATUS m_ncs;
  56. };
  57. class CCMUtil
  58. {
  59. public:
  60. ~CCMUtil();
  61. static CCMUtil & Instance() { return s_instance; }
  62. HRESULT HrGetEntry(const GUID & guid, CMEntry & cm);
  63. HRESULT HrGetEntry(const WCHAR * szEntryName, CMEntry & cm);
  64. void SetEntry(const GUID & guid, const WCHAR * szEntryName, const NETCON_STATUS ncs);
  65. void RemoveEntry(const GUID & guid);
  66. private:
  67. static CCMUtil s_instance;
  68. CRITICAL_SECTION m_CriticalSection;
  69. typedef vector<CMEntry> CMEntryTable;
  70. CMEntryTable m_Table;
  71. CMEntryTable::iterator GetIteratorFromGuid(const GUID & guid);
  72. CCMUtil();
  73. CCMUtil(const CCMUtil &);
  74. };