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.

241 lines
8.0 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name :
  4. logscripting.h
  5. Abstract:
  6. LogScripting.cpp : Declaration of the CLogScripting
  7. Automation compatible logging interface
  8. Author:
  9. Saurab Nog ( saurabn ) 01-Feb-1998
  10. Project:
  11. IIS Logging 5.0
  12. --*/
  13. #ifndef _LOGSCRIPTING_
  14. #define _LOGSCRIPTING_
  15. #include "resource.h" // main symbols
  16. #pragma warning (disable: 4786 4788)
  17. #include <algorithm>
  18. #include <queue>
  19. #include <deque>
  20. #include <functional>
  21. #define INVALID_PLUGIN -1
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CLogScripting
  24. class ATL_NO_VTABLE CLogScripting :
  25. public CComObjectRootEx<CComSingleThreadModel>,
  26. public CComCoClass<CLogScripting, &CLSID_LogScripting>,
  27. public IDispatchImpl<ILogScripting, &IID_ILogScripting, &LIBID_IISLog>
  28. {
  29. public:
  30. CLogScripting();
  31. HRESULT FinalConstruct();
  32. void FinalRelease();
  33. DECLARE_REGISTRY_RESOURCEID(IDR_LOGSCRIPTING)
  34. DECLARE_PROTECT_FINAL_CONSTRUCT()
  35. DECLARE_GET_CONTROLLING_UNKNOWN()
  36. BEGIN_COM_MAP(CLogScripting)
  37. COM_INTERFACE_ENTRY(ILogScripting)
  38. COM_INTERFACE_ENTRY(IDispatch)
  39. END_COM_MAP()
  40. private:
  41. struct FileListEntry
  42. {
  43. WCHAR wcsFileName[MAX_PATH+1];
  44. FILETIME ftCreationTime;
  45. void Copy(const WIN32_FIND_DATAW& x)
  46. {
  47. wcscpy( wcsFileName, x.cFileName);
  48. memcpy( &ftCreationTime, &x.ftCreationTime, sizeof(FILETIME));
  49. }
  50. };
  51. typedef struct FileListEntry *PFileListEntry;
  52. struct FileTimeCompare
  53. {
  54. //
  55. // We need ascending order. So bigger TimeStamp is smaller
  56. //
  57. bool operator()(const PFileListEntry x, const PFileListEntry y) const
  58. {
  59. return ( CompareFileTime(&(x->ftCreationTime), &(y->ftCreationTime)) != -1);
  60. }
  61. };
  62. typedef std::priority_queue<PFileListEntry, std::vector<PFileListEntry>, FileTimeCompare>
  63. FileQ;
  64. private:
  65. //
  66. // Metabase pointer
  67. //
  68. IMSAdminBase* m_pMBCom;
  69. //
  70. // Plugin information
  71. //
  72. typedef struct
  73. {
  74. ILogScripting * pILogScripting;
  75. CLSID clsid;
  76. WCHAR wcsFriendlyName[256];
  77. }
  78. PLUGIN_INFO, *PPLUGIN_INFO;
  79. int m_iNumPlugins, m_iReadPlugin, m_iWritePlugin;
  80. PPLUGIN_INFO m_pPluginInfo;
  81. //
  82. // File Path Information
  83. //
  84. bool m_fDirectory;
  85. HANDLE m_hDirSearchHandle;
  86. WCHAR m_wcsReadFileName[MAX_PATH+1], m_wcsReadDirectoryName[MAX_PATH+1];
  87. //
  88. // Log Time Information
  89. //
  90. DATE m_StartDateTime;
  91. DATE m_EndDateTime;
  92. //
  93. // Flag to indicate end of Records
  94. //
  95. bool m_fEndOfReadRecords;
  96. //
  97. // Directory listing
  98. //
  99. FileQ m_fQueue;
  100. //
  101. // Private member functions
  102. //
  103. int ParseLogFile();
  104. bool GetNextFileName();
  105. int CreateAllPlugins();
  106. bool GetListOfAvailablePlugins();
  107. HRESULT InternalReadLogRecord();
  108. public:
  109. //
  110. // ILogScripting: Copied from the header file generated by MIDL.
  111. //
  112. virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE OpenLogFile(
  113. /* [in] */ BSTR szLogFileName,
  114. /* [defaultvalue][optional][in] */ IOMode Mode = ForReading,
  115. /* [defaultvalue][optional][in] */ BSTR szServiceName = L"",
  116. /* [defaultvalue][optional][in] */ long iServerInstance = 0,
  117. /* [defaultvalue][optional][in] */ BSTR szOutputLogFileFormat = L"");
  118. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CloseLogFiles(
  119. /* [defaultvalue][optional][in] */ IOMode Mode = AllOpenFiles);
  120. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReadFilter(
  121. /* [defaultvalue][optional][in] */ DATE startDateTime = 0,
  122. /* [defaultvalue][optional][in] */ DATE endDateTime = 1000000);
  123. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReadLogRecord( void);
  124. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE AtEndOfLog(
  125. /* [retval][ref][out] */ VARIANT_BOOL __RPC_FAR *pfEndOfRead);
  126. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE WriteLogRecord(
  127. /* [in] */ ILogScripting __RPC_FAR *pILogScripting);
  128. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_DateTime(
  129. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarDateTime);
  130. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServiceName(
  131. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServiceName);
  132. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServerName(
  133. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServerName);
  134. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ClientIP(
  135. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarClientIP);
  136. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_UserName(
  137. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarUserName);
  138. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServerIP(
  139. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServerIP);
  140. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Method(
  141. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarMethod);
  142. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_URIStem(
  143. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarURIStem);
  144. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_URIQuery(
  145. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarURIQuery);
  146. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_TimeTaken(
  147. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarTimeTaken);
  148. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_BytesSent(
  149. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarBytesSent);
  150. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_BytesReceived(
  151. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarBytesReceived);
  152. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Win32Status(
  153. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarWin32Status);
  154. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ProtocolStatus(
  155. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarProtocolStatus);
  156. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServerPort(
  157. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServerPort);
  158. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ProtocolVersion(
  159. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarProtocolVersion);
  160. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_UserAgent(
  161. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarUserAgent);
  162. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Cookie(
  163. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarCookie);
  164. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Referer(
  165. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarReferer);
  166. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_CustomFields(
  167. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarCustomFieldsArray);
  168. };
  169. #endif //_LOGSCRIPTING_