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.

88 lines
1.7 KiB

  1. //+------------------------------------------------------------
  2. //
  3. // Copyright (C) 2000, Microsoft Corporation
  4. //
  5. // File: pldapwrap.h
  6. //
  7. // Contents: Class to refcount a PLDAP handle
  8. //
  9. // Classes:
  10. // CRefcountWrap: generic refcounting wrap class
  11. // CPLDAPWrap
  12. //
  13. // Functions:
  14. //
  15. // History:
  16. // jstamerj 2000/02/25 15:18:15: Created.
  17. //
  18. //-------------------------------------------------------------
  19. class CRefcountWrap
  20. {
  21. public:
  22. CRefcountWrap()
  23. {
  24. m_lRefCount = 1;
  25. }
  26. LONG AddRef()
  27. {
  28. return InterlockedIncrement(&m_lRefCount);
  29. }
  30. LONG Release()
  31. {
  32. LONG lRet;
  33. lRet = InterlockedDecrement(&m_lRefCount);
  34. if(lRet == 0)
  35. FinalRelease();
  36. return lRet;
  37. }
  38. virtual VOID FinalRelease() = 0;
  39. private:
  40. LONG m_lRefCount;
  41. };
  42. CatDebugClass(CPLDAPWrap),
  43. public CRefcountWrap
  44. {
  45. public:
  46. CPLDAPWrap(
  47. ISMTPServerEx *pISMTPServerEx,
  48. LPSTR pszHost,
  49. DWORD dwPort);
  50. VOID SetPLDAP(PLDAP pldap)
  51. {
  52. m_pldap = pldap;
  53. }
  54. VOID FinalRelease()
  55. {
  56. delete this;
  57. }
  58. operator PLDAP()
  59. {
  60. return PLDAP();
  61. }
  62. PLDAP GetPLDAP()
  63. {
  64. return m_pldap;
  65. }
  66. private:
  67. #define SIGNATURE_CPLDAPWRAP (DWORD)'ADLP'
  68. #define SIGNATURE_CPLDAPWRAP_INVALID (DWORD)'XDLP'
  69. ~CPLDAPWrap()
  70. {
  71. if(m_pldap)
  72. ldap_unbind(m_pldap);
  73. _ASSERT(m_dwSig == SIGNATURE_CPLDAPWRAP);
  74. m_dwSig = SIGNATURE_CPLDAPWRAP_INVALID;
  75. }
  76. private:
  77. DWORD m_dwSig;
  78. PLDAP m_pldap;
  79. };