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.

108 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: E V T D I A G . C P P
  7. //
  8. // Contents: Eventing manager diagnostic functions
  9. //
  10. // Notes:
  11. //
  12. // Author: danielwe 2000/10/2
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include <upnpatl.h>
  18. #include "hostp.h"
  19. #include "evtapi.h"
  20. #include "evtdiag.h"
  21. #include "ncstring.h"
  22. extern CRITICAL_SECTION g_csListEventSource;
  23. extern UPNP_EVENT_SOURCE * g_pesList;
  24. STDMETHODIMP CUPnPEventingManagerDiag::GetEventSourceInfo(
  25. DWORD *pces, UDH_EVTSRC_INFO **prgesInfo)
  26. {
  27. HRESULT hr = S_OK;
  28. UPNP_EVENT_SOURCE * pesCur;
  29. UDH_EVTSRC_INFO * rguei = NULL;
  30. DWORD ces = 0;
  31. DWORD ies;
  32. Assert(pces);
  33. Assert(prgesInfo);
  34. *pces = 0;
  35. *prgesInfo = NULL;
  36. EnterCriticalSection(&g_csListEventSource);
  37. if (g_pesList)
  38. {
  39. for (pesCur = g_pesList; pesCur; pesCur = pesCur->pesNext)
  40. {
  41. ces++;
  42. }
  43. rguei = (UDH_EVTSRC_INFO *)CoTaskMemAlloc(sizeof(UDH_EVTSRC_INFO) * ces);
  44. if (rguei)
  45. {
  46. ZeroMemory(rguei, sizeof(UDH_EVTSRC_INFO) * ces);
  47. for (ies = 0, pesCur = g_pesList;
  48. pesCur;
  49. pesCur = pesCur->pesNext, ies++)
  50. {
  51. UPNP_SUBSCRIBER * psubCur;
  52. for (psubCur = pesCur->psubList; psubCur; psubCur = psubCur->psubNext)
  53. {
  54. rguei[ies].cSubs++;
  55. }
  56. rguei[ies].szEsid = COMSzFromWsz(pesCur->szEsid);
  57. rguei[ies].rgSubs = (UDH_SUBSCRIBER_INFO *)CoTaskMemAlloc(sizeof(UDH_SUBSCRIBER_INFO) * rguei[ies].cSubs);
  58. if (rguei[ies].rgSubs)
  59. {
  60. DWORD isub;
  61. ZeroMemory(rguei[ies].rgSubs, sizeof(UDH_SUBSCRIBER_INFO) * rguei[ies].cSubs);
  62. for (isub = 0, psubCur = pesCur->psubList;
  63. psubCur;
  64. isub++, psubCur = psubCur->psubNext)
  65. {
  66. rguei[ies].rgSubs[isub].csecTimeout = psubCur->csecTimeout;
  67. rguei[ies].rgSubs[isub].ftTimeout = psubCur->ftTimeout;
  68. rguei[ies].rgSubs[isub].iSeq = psubCur->iSeq;
  69. rguei[ies].rgSubs[isub].szDestUrl = COMSzFromWsz(psubCur->rgszUrl[0]);
  70. rguei[ies].rgSubs[isub].szSid = COMSzFromWsz(psubCur->szSid);
  71. }
  72. }
  73. else
  74. {
  75. hr = E_OUTOFMEMORY;
  76. }
  77. }
  78. }
  79. else
  80. {
  81. hr = E_OUTOFMEMORY;
  82. }
  83. }
  84. if (SUCCEEDED(hr))
  85. {
  86. *prgesInfo = rguei;
  87. *pces = ces;
  88. }
  89. LeaveCriticalSection(&g_csListEventSource);
  90. return hr;
  91. }