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.

104 lines
2.8 KiB

  1. #ifndef __WBEM_LOGFILE_CONSUMER__H_
  2. #define __WBEM_LOGFILE_CONSUMER__H_
  3. #include <unk.h>
  4. #include <wbemidl.h>
  5. #include <ErrorObj.h>
  6. #include "txttempl.h"
  7. #include <stdio.h>
  8. class CLogFileConsumer : public CUnk
  9. {
  10. protected:
  11. class XProvider : public CImpl<IWbemEventConsumerProvider, CLogFileConsumer>
  12. {
  13. public:
  14. XProvider(CLogFileConsumer* pObj)
  15. : CImpl<IWbemEventConsumerProvider, CLogFileConsumer>(pObj){}
  16. HRESULT STDMETHODCALLTYPE FindConsumer(
  17. IWbemClassObject* pLogicalConsumer,
  18. IWbemUnboundObjectSink** ppConsumer);
  19. } m_XProvider;
  20. friend XProvider;
  21. class XInit : public CImpl<IWbemProviderInit, CLogFileConsumer>
  22. {
  23. public:
  24. XInit(CLogFileConsumer* pObj)
  25. : CImpl<IWbemProviderInit, CLogFileConsumer>(pObj){}
  26. HRESULT STDMETHODCALLTYPE Initialize(
  27. LPWSTR, LONG, LPWSTR, LPWSTR, IWbemServices*, IWbemContext*,
  28. IWbemProviderInitSink*);
  29. } m_XInit;
  30. friend XInit;
  31. public:
  32. CLogFileConsumer(CLifeControl* pControl = NULL, IUnknown* pOuter = NULL)
  33. : CUnk(pControl, pOuter), m_XProvider(this), m_XInit(this)
  34. {}
  35. ~CLogFileConsumer(){}
  36. void* GetInterface(REFIID riid);
  37. };
  38. class CLogFileSink : public CUnk
  39. {
  40. protected:
  41. class XSink : public CImpl<IWbemUnboundObjectSink, CLogFileSink>
  42. {
  43. public:
  44. XSink(CLogFileSink* pObj) :
  45. CImpl<IWbemUnboundObjectSink, CLogFileSink>(pObj){}
  46. HRESULT STDMETHODCALLTYPE IndicateToConsumer(
  47. IWbemClassObject* pLogicalConsumer, long lNumObjects,
  48. IWbemClassObject** apObjects);
  49. } m_XSink;
  50. friend XSink;
  51. protected:
  52. CTextTemplate m_Template;
  53. WString m_wsFile;
  54. // determines whether file is too large, archives old if needed
  55. // probably returns INVALID_HANDLE_VALUE on error
  56. HRESULT GetFileHandle(HANDLE& handle);
  57. // don't access this directly. use GetFileHandle
  58. HANDLE m_hFile;
  59. ErrorObj* m_pErrorObj;
  60. bool m_bUnicode; // do the file be unicode?
  61. UINT64 m_maxFileSize;
  62. bool IsFileTooBig(UINT64 maxFileSize, HANDLE hFile);
  63. bool IsFileTooBig(UINT64 maxFileSize, WString& fileName);
  64. HRESULT ArchiveFile(WString& fileName);
  65. bool GetNumericExtension(WCHAR* pName, int& foundNumber);
  66. void OpenThisFile(WString fname, bool openExisting, bool allowDelete);
  67. void CloseCurrentFile();
  68. public:
  69. CLogFileSink(CLifeControl* pControl = NULL)
  70. : CUnk(pControl), m_XSink(this),m_pErrorObj(NULL),
  71. m_hFile(INVALID_HANDLE_VALUE),
  72. m_maxFileSize(0), m_bUnicode(false)
  73. {}
  74. HRESULT Initialize(IWbemClassObject* pLogicalConsumer);
  75. ~CLogFileSink();
  76. void* GetInterface(REFIID riid);
  77. };
  78. #endif