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.

179 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name :
  4. logpublic.cxx
  5. Abstract:
  6. Public Log COM Object
  7. Author:
  8. Saurab Nog (SaurabN) 25-March-1998
  9. --*/
  10. #include "precomp.hxx"
  11. #include "comlog.hxx"
  12. CInetLogPublic::CInetLogPublic(
  13. VOID
  14. ):
  15. m_pContext ( NULL),
  16. m_refCount ( 0)
  17. {
  18. InitializeListHead(&m_ListEntry);
  19. } // CInetLogPublic::CInetLogPublic
  20. CInetLogPublic::~CInetLogPublic(
  21. VOID
  22. )
  23. {
  24. } // CInetLogPublic::~CInetLogPublic
  25. ULONG
  26. CInetLogPublic::AddRef(
  27. VOID
  28. )
  29. {
  30. DWORD dwRefCount = InterlockedIncrement( &m_refCount );
  31. return(dwRefCount);
  32. } // CInetLogPublic::AddRef
  33. ULONG
  34. CInetLogPublic::Release(
  35. VOID
  36. )
  37. {
  38. DWORD dwRefCount = InterlockedDecrement( &m_refCount );
  39. if (dwRefCount == 0)
  40. {
  41. EnterCriticalSection( &COMLOG_CONTEXT::sm_listLock );
  42. RemoveEntryList(&m_ListEntry);
  43. LeaveCriticalSection( &COMLOG_CONTEXT::sm_listLock );
  44. delete this;
  45. }
  46. return(dwRefCount);
  47. } // CInetLogPublic::Release
  48. HRESULT
  49. CInetLogPublic::QueryInterface(
  50. REFIID riid,
  51. VOID **ppObj
  52. )
  53. {
  54. if ( riid == IID_IUnknown ||
  55. riid == IID_IInetLogPublic)
  56. {
  57. *ppObj = (CInetLogPublic *)this;
  58. AddRef();
  59. return(NO_ERROR);
  60. }
  61. else
  62. {
  63. return(E_NOINTERFACE);
  64. }
  65. } // CInetLogPublic::QueryInterface
  66. HRESULT
  67. CInetLogPublic::SetLogInstance(
  68. LPSTR szInstance
  69. )
  70. {
  71. PLIST_ENTRY listEntry;
  72. COMLOG_CONTEXT* pContext = NULL;
  73. HRESULT hr = E_FAIL;
  74. //
  75. // Search through the context list for a matching context
  76. //
  77. EnterCriticalSection( &COMLOG_CONTEXT::sm_listLock );
  78. for ( listEntry = COMLOG_CONTEXT::sm_ContextListHead.Flink;
  79. listEntry != &COMLOG_CONTEXT::sm_ContextListHead;
  80. listEntry = listEntry->Flink )
  81. {
  82. pContext = (COMLOG_CONTEXT*)CONTAINING_RECORD(
  83. listEntry,
  84. COMLOG_CONTEXT,
  85. m_ContextListEntry
  86. );
  87. if (0 != strcmp(pContext->m_strInstanceName.QueryStr(), szInstance))
  88. {
  89. pContext = NULL;
  90. }
  91. else
  92. {
  93. break;
  94. }
  95. }
  96. if ( NULL != pContext)
  97. {
  98. if (NULL != m_pContext)
  99. {
  100. RemoveEntryList(&m_ListEntry);
  101. }
  102. m_pContext = pContext;
  103. InsertTailList(
  104. &m_pContext->m_PublicListEntry,
  105. &m_ListEntry
  106. );
  107. hr = S_OK;
  108. }
  109. LeaveCriticalSection( &COMLOG_CONTEXT::sm_listLock );
  110. return hr;
  111. }
  112. HRESULT
  113. CInetLogPublic::LogInformation(
  114. IInetLogInformation *pLogObj
  115. )
  116. {
  117. if (NULL == m_pContext)
  118. {
  119. return (E_HANDLE);
  120. }
  121. m_pContext->LogInformation(pLogObj);
  122. return S_OK;
  123. }
  124. HRESULT
  125. CInetLogPublic::LogCustomInformation(
  126. IN DWORD cCount,
  127. IN PCUSTOM_LOG_DATA pCustomLogData,
  128. IN LPSTR szHeaderSuffix
  129. )
  130. {
  131. if (NULL == m_pContext)
  132. {
  133. return (E_HANDLE);
  134. }
  135. m_pContext->LogCustomInformation(cCount, pCustomLogData, szHeaderSuffix);
  136. return S_OK;
  137. }