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.

221 lines
8.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name :
  4. logscript.hxx
  5. Abstract:
  6. Base implementation for ILogScripting - Automation compatible logging interface
  7. Author:
  8. Saurab Nog ( saurabn ) 01-Feb-1998
  9. Project:
  10. IIS Logging 5.0
  11. --*/
  12. #ifndef _LOGSCRIPT_
  13. #define _LOGSCRIPT_
  14. typedef struct _CUSTOM_FIELD_ENTRY
  15. {
  16. CHAR szHeader[32];
  17. PCHAR pchData;
  18. }
  19. CUSTOM_FIELD_ENTRY, *PCUSTOM_FIELD_ENTRY;
  20. #define MAX_CUSTOM_FIELDS 20
  21. typedef struct _INETLOGLINE
  22. {
  23. LPSTR pszClientHostName;
  24. LPSTR pszClientUserName;
  25. LPSTR pszServerAddress; // input ip address for connection
  26. LPSTR pszOperation; // eg: 'get' in FTP
  27. LPSTR pszTarget; // target path/machine name
  28. LPSTR pszParameters; // string containing parameters.
  29. LPSTR pszVersion; // protocol version string.
  30. LPSTR pszHTTPHeader; // Header Information
  31. LPSTR pszBytesSent; // count of bytes sent
  32. LPSTR pszBytesRecvd; // count of bytes recvd
  33. LPSTR pszTimeForProcessing; // time required for processing
  34. LPSTR pszWin32Status; // Win32 error code. 0 for success
  35. LPSTR pszProtocolStatus; // status: whatever service wants.
  36. LPSTR pszPort;
  37. DATE DateTime; // Date & Time
  38. LPSTR pszSiteName; // Service name (not put in https log)
  39. LPSTR pszComputerName; // netbios name of Server
  40. LPSTR pszUserAgent; // User Agent - Browser type
  41. LPSTR pszCookie;
  42. LPSTR pszReferer; // Referring URL.
  43. int iCustomFieldsCount;
  44. CUSTOM_FIELD_ENTRY CustomFields[MAX_CUSTOM_FIELDS];
  45. // custom fields. Includes UserAgent, Referer & Cookie
  46. }
  47. *LPINET_LOGLINE, INET_LOGLINE;
  48. class CLogScript :
  49. public IDispatchImpl<ILogScripting, &IID_ILogScripting, &LIBID_IISLog>
  50. // The Log Scripting Interface
  51. {
  52. public:
  53. CLogScript();
  54. protected:
  55. virtual ~CLogScript();
  56. virtual HRESULT
  57. ReadFileLogRecord(
  58. IN FILE *fpLogFile,
  59. IN LPINET_LOGLINE pInetLogLine,
  60. IN PCHAR pszLogLine,
  61. IN DWORD dwLogLineSize
  62. ) = 0;
  63. virtual HRESULT
  64. WriteFileLogRecord(
  65. IN FILE *fpLogFile,
  66. IN ILogScripting *pILogScripting,
  67. IN bool fWriteHeader
  68. ) = 0;
  69. //
  70. // Support methods
  71. //
  72. inline VOID SetVariantToBstr (VARIANT * pVar, LPSTR pCh);
  73. inline VOID SetVariantToLong (VARIANT * pVar, LPSTR pCh);
  74. BSTR GetBstrFromVariant (VARIANT * pVar);
  75. DWORD GetLongFromVariant (VARIANT * pVar, CHAR * pBuffer);
  76. private:
  77. VOID LockCS() { EnterCriticalSection( &m_csLock ); }
  78. VOID UnlockCS() { LeaveCriticalSection( &m_csLock ); }
  79. VOID ResetInetLogLine(INET_LOGLINE& InetLogLine);
  80. CRITICAL_SECTION m_csLock;
  81. FILE *m_pInputLogFile;
  82. STR m_strInputLogFileName;
  83. INET_LOGLINE ReadInetLogLine;
  84. FILE *m_pOutputLogFile;
  85. STR m_strOutputLogFileName;
  86. PCHAR m_pszLogLine;
  87. DWORD m_dwLogLineSize;
  88. BSTR m_szEmpty;
  89. public:
  90. //
  91. // ILogScripting: Copied from the header file generated by MIDL.
  92. //
  93. virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE OpenLogFile(
  94. /* [in] */ BSTR szLogFileName,
  95. /* [defaultvalue][optional][in] */ IOMode Mode = ForReading,
  96. /* [defaultvalue][optional][in] */ BSTR szServiceName = L"",
  97. /* [defaultvalue][optional][in] */ long iServerInstance = 0,
  98. /* [defaultvalue][optional][in] */ BSTR szOutputLogFileFormat = L"");
  99. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CloseLogFiles(
  100. /* [defaultvalue][optional][in] */ IOMode Mode = AllOpenFiles);
  101. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReadFilter(
  102. /* [defaultvalue][optional][in] */ DATE startDateTime = 0,
  103. /* [defaultvalue][optional][in] */ DATE endDateTime = 1000000);
  104. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReadLogRecord( void);
  105. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE AtEndOfLog(
  106. /* [retval][ref][out] */ VARIANT_BOOL __RPC_FAR *pfEndOfRead);
  107. virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE WriteLogRecord(
  108. /* [in] */ ILogScripting __RPC_FAR *pILogScripting);
  109. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_DateTime(
  110. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarDateTime);
  111. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServiceName(
  112. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServiceName);
  113. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServerName(
  114. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServerName);
  115. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ClientIP(
  116. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarClientIP);
  117. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_UserName(
  118. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarUserName);
  119. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServerIP(
  120. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServerIP);
  121. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Method(
  122. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarMethod);
  123. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_URIStem(
  124. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarURIStem);
  125. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_URIQuery(
  126. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarURIQuery);
  127. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_TimeTaken(
  128. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarTimeTaken);
  129. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_BytesSent(
  130. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarBytesSent);
  131. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_BytesReceived(
  132. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarBytesReceived);
  133. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Win32Status(
  134. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarWin32Status);
  135. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ProtocolStatus(
  136. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarProtocolStatus);
  137. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ServerPort(
  138. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarServerPort);
  139. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_ProtocolVersion(
  140. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarProtocolVersion);
  141. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_UserAgent(
  142. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarUserAgent);
  143. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Cookie(
  144. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarCookie);
  145. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Referer(
  146. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarReferer);
  147. virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_CustomFields(
  148. /* [retval][ref][out] */ VARIANT __RPC_FAR *pvarCustomFieldsArray);
  149. };
  150. #endif // _LOGSCRIPT_