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.

301 lines
8.4 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name :
  4. cuslog.h
  5. Abstract:
  6. MS Custom Format logging control header file
  7. Author:
  8. Terence Kwan ( terryk ) 18-Sep-1996
  9. Project:
  10. IIS Logging 3.0
  11. --*/
  12. #ifndef _CUSLOGC_H_
  13. #define _CUSLOGC_H_
  14. typedef PVOID *PPVOID;
  15. #define MAX_CUSTLOG_FIELDS 30
  16. typedef struct
  17. {
  18. STR strKeyPath;
  19. DWORD dwPropertyID;
  20. DWORD dwPropertyMask;
  21. DWORD dwPropertyDataType;
  22. STR strW3CHeader;
  23. BOOL fEnabled;
  24. } LOG_PROPERTY_INFO, *PLOG_PROPERTY_INFO, **PPLOG_PROPERTY_INFO;
  25. class CCustomPropHashTable
  26. : public CTypedHashTable< CCustomPropHashTable, LOG_PROPERTY_INFO, const char *>
  27. {
  28. public:
  29. CCustomPropHashTable()
  30. : CTypedHashTable<CCustomPropHashTable, LOG_PROPERTY_INFO,
  31. const char *>("ExtLogC", LK_DFLT_MAXLOAD, LK_SMALL_TABLESIZE)
  32. {
  33. m_pLogPropArray = NULL;
  34. m_cLogPropItems = 0;
  35. m_fInitialized =FALSE;
  36. m_dwRefCounter = 1;
  37. }
  38. ~CCustomPropHashTable()
  39. {
  40. if (NULL != m_pLogPropArray)
  41. {
  42. delete [] m_pLogPropArray;
  43. m_pLogPropArray = NULL;
  44. }
  45. }
  46. static const char*
  47. ExtractKey(const LOG_PROPERTY_INFO* pLogPropInfo)
  48. {
  49. return pLogPropInfo->strKeyPath.QueryStr();
  50. }
  51. static DWORD
  52. CalcKeyHash(const char* pszKey)
  53. {
  54. return HashStringNoCase(pszKey);
  55. }
  56. static bool
  57. EqualKeys(const char* pszKey1, const char* pszKey2)
  58. {
  59. return _stricmp(pszKey1, pszKey2) == 0;
  60. }
  61. static void
  62. AddRefRecord(const LOG_PROPERTY_INFO*, int)
  63. {
  64. }
  65. BOOL FillHashTable(MB& mb);
  66. VOID SetPopulationState(MB& mb);
  67. BOOL InitializeFromMB (MB &mb,const char *path);
  68. BOOL InitFrom (CCustomPropHashTable& src);
  69. VOID ClearTableAndStorage ();
  70. VOID
  71. AddRef ()
  72. {
  73. InterlockedIncrement ((long *)&m_dwRefCounter);
  74. }
  75. DWORD
  76. Release ()
  77. {
  78. DWORD retVal;
  79. DBG_ASSERT (m_dwRefCounter);
  80. retVal = InterlockedDecrement((long *)&m_dwRefCounter);
  81. return retVal;
  82. }
  83. private:
  84. CCustomPropHashTable(const CCustomPropHashTable &);
  85. void operator=(const CCustomPropHashTable &);
  86. BOOL PopulateHash(MB& mb, LPCSTR szPath, DWORD& cItems, bool fCountOnly = false);
  87. PLOG_PROPERTY_INFO m_pLogPropArray;
  88. DWORD m_cLogPropItems;
  89. BOOL m_fInitialized;
  90. DWORD m_dwRefCounter;
  91. };
  92. class CEXTLOG :
  93. public CLogFileCtrl,
  94. public CLogScript,
  95. public CComCoClass<CEXTLOG, &CLSID_EXTLOG>
  96. {
  97. public:
  98. CEXTLOG();
  99. BEGIN_COM_MAP(CEXTLOG)
  100. COM_INTERFACE_ENTRY(ILogPlugin)
  101. COM_INTERFACE_ENTRY(ILogPluginEx)
  102. COM_INTERFACE_ENTRY(ILogScripting)
  103. COM_INTERFACE_ENTRY(IDispatch)
  104. END_COM_MAP()
  105. virtual HRESULT STDMETHODCALLTYPE
  106. InitializeLog(
  107. IN LPCSTR SiteName,
  108. IN LPCSTR MetabasePath,
  109. IN PCHAR pvIMDCOM
  110. );
  111. virtual HRESULT STDMETHODCALLTYPE
  112. TerminateLog( VOID);
  113. virtual HRESULT STDMETHODCALLTYPE
  114. LogCustomInformation(
  115. IN DWORD cCount,
  116. IN PCUSTOM_LOG_DATA pCustomLogData,
  117. IN LPSTR szHeaderSuffix
  118. );
  119. protected:
  120. ~CEXTLOG();
  121. virtual void InternalGetConfig( PINETLOG_CONFIGURATIONA pLogConfig );
  122. virtual void InternalGetExtraLoggingFields(
  123. PDWORD pcbSize,
  124. PCHAR pszFieldsList);
  125. virtual DWORD GetRegParameters( LPCSTR pszRegKey, LPVOID );
  126. virtual BOOL WriteLogDirectives( IN DWORD Sludge );
  127. virtual BOOL WriteCustomLogDirectives( IN DWORD Sludge );
  128. virtual VOID FormNewLogFileName( IN LPSYSTEMTIME pstNow );
  129. virtual BOOL FormatLogBuffer(
  130. IN IInetLogInformation *pLogObj,
  131. IN LPSTR pBuf,
  132. IN DWORD *pcbSize,
  133. OUT SYSTEMTIME *pSystemTime
  134. );
  135. BOOL NormalFormatBuffer(
  136. IInetLogInformation * ppvDataObj,
  137. LPSTR, DWORD *cbSize,
  138. SYSTEMTIME *pLocalTime);
  139. virtual DWORD QueryLogFormat() {return(INET_LOG_FORMAT_EXTENDED);}
  140. virtual LPCSTR QueryNoPeriodPattern( );
  141. VOID GetFormatHeader( STR* strHeader );
  142. virtual HRESULT
  143. ReadFileLogRecord(
  144. IN FILE *fpLogFile,
  145. IN LPINET_LOGLINE pInetLogLine,
  146. IN PCHAR pszLogLine,
  147. IN DWORD dwLogLineSize
  148. );
  149. virtual HRESULT
  150. WriteFileLogRecord(
  151. IN FILE *fpLogFile,
  152. IN ILogScripting *pILogScripting,
  153. IN bool fWriteHeader
  154. );
  155. BOOL ConvertW3CDateToVariantDate(PCHAR szDateString, PCHAR szTimeString, DATE * pDateTime);
  156. DWORD ConvertDataToString(DWORD dwPropertyType, PVOID pData, PCHAR pBuffer, DWORD dwBufferSize);
  157. private:
  158. CEXTLOG(const CEXTLOG &);
  159. void operator=(const CEXTLOG &);
  160. DWORD m_lMask;
  161. DWORD m_fUseLocalTimeForRollover;
  162. EXTLOG_DATETIME_CACHE m_DateTimeCache;
  163. ASCLOG_DATETIME_CACHE *m_pLocalTimeCache;
  164. //
  165. // ILogScripting related declarations
  166. //
  167. CHAR m_szDate[15], m_szTime[15];
  168. DWORD dwDatePos;
  169. DWORD dwTimePos;
  170. DWORD dwClientIPPos;
  171. DWORD dwUserNamePos;
  172. DWORD dwSiteNamePos;
  173. DWORD dwComputerNamePos;
  174. DWORD dwServerIPPos;
  175. DWORD dwMethodPos;
  176. DWORD dwURIStemPos;
  177. DWORD dwURIQueryPos;
  178. DWORD dwHTTPStatusPos;
  179. DWORD dwWin32StatusPos;
  180. DWORD dwBytesSentPos;
  181. DWORD dwBytesRecvPos;
  182. DWORD dwTimeTakenPos;
  183. DWORD dwServerPortPos;
  184. DWORD dwVersionPos;
  185. DWORD dwCookiePos;
  186. DWORD dwUserAgentPos;
  187. DWORD dwRefererPos;
  188. typedef struct
  189. {
  190. CHAR szW3CHeader[32];
  191. VARIANT varData;
  192. } LOG_FIELDS, *PLOG_FIELDS;
  193. PLOG_FIELDS m_pLogFields;
  194. STR m_szWriteHeader;
  195. //
  196. // Custom Logging related declarations
  197. //
  198. STR m_strHeaderSuffix;
  199. DWORD m_cPrevCustLogItems;
  200. PLOG_PROPERTY_INFO m_pPrevCustLogItems[MAX_CUSTLOG_FIELDS];
  201. TS_RESOURCE m_tsCustLoglock;
  202. VOID LockCustLogShared() { m_tsCustLoglock.Lock(TSRES_LOCK_READ); }
  203. VOID LockCustLogExclusive() { m_tsCustLoglock.Lock(TSRES_LOCK_WRITE); }
  204. VOID LockCustLogConvertExclusive() { m_tsCustLoglock.Convert(TSRES_CONV_WRITE); }
  205. VOID UnlockCustLog() { m_tsCustLoglock.Unlock(); }
  206. DWORD FormatCustomLogBuffer(DWORD cItems,
  207. PPLOG_PROPERTY_INFO pPropInfo,
  208. PPVOID pPropData,
  209. LPCSTR szDateTime,
  210. LPSTR szLogLine,
  211. DWORD cchLogLine
  212. );
  213. void BuildCustomLogHeader( DWORD cItems,
  214. PPLOG_PROPERTY_INFO pPropInfo,
  215. LPCSTR szDateTime,
  216. LPCSTR szHeaderSuffix,
  217. STR& strHeader);
  218. CCustomPropHashTable m_HashTable;
  219. BOOL m_fHashTablePopulated;
  220. BOOL m_fWriteHeadersInitialized;
  221. }; // CEXTLOG
  222. #endif // _CUSLOGC_H_