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.

160 lines
5.4 KiB

  1. #ifndef _FILECTL_HXX_
  2. #define _FILECTL_HXX_
  3. class ATL_NO_VTABLE CLogFileCtrl :
  4. public ILogPluginEx,
  5. public CComObjectRootEx<CComMultiThreadModel>
  6. {
  7. public:
  8. CLogFileCtrl();
  9. inline DWORD QueryPeriod() {return m_dwPeriod;}
  10. inline LPCSTR QueryLogFileDirectory() {return m_strLogFileDirectory.QueryStr();}
  11. inline LPCSTR QueryInstanceName( ) { return m_strInstanceName.QueryStr(); }
  12. inline LPCSTR QueryMetabasePath( ) { return m_strMetabasePath.QueryStr(); }
  13. inline DWORD QuerySizeForTruncation() {return m_cbSizeForTruncation;}
  14. //
  15. // ATL Interface
  16. //
  17. DECLARE_NO_REGISTRY( );
  18. //
  19. // ILogPluginEx Interface
  20. //
  21. HRESULT STDMETHODCALLTYPE
  22. InitializeLog(
  23. IN LPCSTR InstanceName,
  24. IN LPCSTR MetabasePath,
  25. IN PCHAR pvIMDCOM );
  26. HRESULT STDMETHODCALLTYPE
  27. TerminateLog( VOID );
  28. HRESULT STDMETHODCALLTYPE
  29. LogInformation( IInetLogInformation *pLogObj );
  30. HRESULT STDMETHODCALLTYPE
  31. SetConfig( IN DWORD cbSize, PBYTE Log );
  32. HRESULT STDMETHODCALLTYPE
  33. GetConfig( IN DWORD cbSize, PBYTE Log );
  34. HRESULT STDMETHODCALLTYPE
  35. QueryExtraLoggingFields(PDWORD cbSize, PCHAR szParameters);
  36. HRESULT STDMETHODCALLTYPE
  37. LogCustomInformation(
  38. IN DWORD cCount,
  39. IN PCUSTOM_LOG_DATA pCustomLogData,
  40. IN LPSTR szHeaderSuffix
  41. );
  42. friend VOID WINAPI LoggingSchedulerCallback( PVOID pContext);
  43. protected:
  44. ILOG_FILE *m_pLogFile;
  45. LPVOID m_pvIMDCOM;
  46. VOID Lock() { EnterCriticalSection( &m_csLock ); }
  47. VOID Unlock() { LeaveCriticalSection( &m_csLock ); }
  48. virtual ~CLogFileCtrl();
  49. inline VOID SetPeriod( DWORD dwPeriod )
  50. {m_dwPeriod = dwPeriod;}
  51. inline VOID SetSizeForTruncation( DWORD dwSizeForTruncation)
  52. { m_cbSizeForTruncation = dwSizeForTruncation; }
  53. inline VOID IncrementBytesWritten( DWORD dwBytesWritten)
  54. { m_cbTotalWritten.QuadPart = m_cbTotalWritten.QuadPart + (ULONGLONG)dwBytesWritten; };
  55. inline BOOL IsFileOverFlowForCB( IN DWORD cbReqd)
  56. {
  57. if ( QueryPeriod( ) != INET_LOG_PERIOD_NONE )
  58. { return(FALSE); }
  59. if (m_cbSizeForTruncation == FILE_SIZE_LOW_MAX)
  60. return FALSE;
  61. else
  62. return(( m_cbTotalWritten.QuadPart + (ULONGLONG)cbReqd) >= (ULONGLONG)m_cbSizeForTruncation);
  63. }
  64. virtual DWORD GetRegParameters( LPCSTR strRegKey, LPVOID pvIMDCOM );
  65. virtual VOID FormNewLogFileName( IN LPSYSTEMTIME pstNow ) = 0;
  66. VOID I_FormNewLogFileName(IN LPSYSTEMTIME pstNow, IN LPCSTR LogPrefixName);
  67. virtual VOID InternalGetConfig( PINETLOG_CONFIGURATIONA pLogConfig );
  68. virtual VOID InternalGetExtraLoggingFields( PDWORD pcbSize, PCHAR pszFieldsList);
  69. virtual LPCSTR QueryNoPeriodPattern( ) = 0;
  70. virtual DWORD QueryLogFormat() = 0;
  71. virtual BOOL FormatLogBuffer(
  72. IN IInetLogInformation *pLogObj,
  73. IN LPSTR pBuf,
  74. IN DWORD *cbSize,
  75. OUT SYSTEMTIME *pLocalTime
  76. ) = 0;
  77. virtual BOOL WriteLogDirectives( IN DWORD Sludge );
  78. virtual BOOL WriteCustomLogDirectives( IN DWORD Sludge );
  79. VOID WriteLogInformation(
  80. IN SYSTEMTIME& stNow,
  81. IN PCHAR pBuf,
  82. IN DWORD dwSize,
  83. IN BOOL fCustom,
  84. IN BOOL fResetHeaders
  85. );
  86. private:
  87. DWORD m_sequence;
  88. SYSTEMTIME m_stCurrentFile;
  89. ULARGE_INTEGER m_cbTotalWritten;
  90. DWORD m_cbSizeForTruncation;
  91. DWORD m_dwPeriod;
  92. BOOL m_fFirstLog;
  93. DWORD m_TickResumeOpen;
  94. DWORD m_dwSchedulerCookie;
  95. STR m_strInstanceName;
  96. STR m_strMetabasePath;
  97. STR m_strLogFileDirectory;
  98. STR m_strLogFileName;
  99. BOOL m_fInTerminate;
  100. BOOL m_fDiskFullShutdown;
  101. BOOL m_fUsingCustomHeaders;
  102. CRITICAL_SECTION m_csLock;
  103. BOOL OpenLogFile( PSYSTEMTIME pst );
  104. BOOL OpenNewLogFile( PSYSTEMTIME pst );
  105. VOID SetLogFileDirectory( LPCSTR pszDir );
  106. DWORD ScheduleCallback(SYSTEMTIME& stNow);
  107. };
  108. DWORD FastDwToA(CHAR* pBuf, DWORD dwV);
  109. CHAR * SkipWhite (CHAR *cp);
  110. VOID WINAPI LoggingSchedulerCallback( PVOID pContext);
  111. #endif