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.

190 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name :
  4. logobj.cxx
  5. Abstract:
  6. Log COM Object
  7. Author:
  8. Johnson Apacible (JohnsonA) 02-April-1997
  9. --*/
  10. #include "precomp.hxx"
  11. #define DLL_IMPLEMENTATION
  12. #include <ilogobj.hxx>
  13. #include <http.h>
  14. #include <httpp.h>
  15. #include "logging.h"
  16. #include "colog.hxx"
  17. LPSTR ReturnStringInfo(LPSTR pBuf,
  18. LPDWORD pcbBuf,
  19. LPCSTR pszInfo,
  20. DWORD cchInfo)
  21. /*--
  22. Support the weird custom logging semantics. Do the copy of the
  23. string from the value we have to the buffer provided if it is big
  24. enough or return the value if no buffer is provided
  25. ++*/
  26. {
  27. if (pBuf != NULL)
  28. {
  29. if (*pcbBuf >= cchInfo)
  30. {
  31. memcpy(pBuf, pszInfo, cchInfo);
  32. }
  33. else
  34. {
  35. *pcbBuf = cchInfo;
  36. return NULL;
  37. }
  38. }
  39. *pcbBuf = cchInfo;
  40. return (LPSTR) pszInfo;
  41. }
  42. LPSTR STDMETHODCALLTYPE
  43. CInetLogInformation::GetSiteName(IN PCHAR pszSiteName,
  44. IN PDWORD pcbSize)
  45. {
  46. return ReturnStringInfo(pszSiteName,
  47. pcbSize,
  48. m_pLogContext->QueryUlLogData()->ServiceName,
  49. m_pLogContext->QueryUlLogData()->ServiceNameLength);
  50. } // GetSiteName
  51. LPSTR STDMETHODCALLTYPE
  52. CInetLogInformation::GetComputerName(IN PCHAR pszComputerName,
  53. IN PDWORD pcbSize)
  54. {
  55. return ReturnStringInfo(pszComputerName,
  56. pcbSize,
  57. g_pszComputerName,
  58. (DWORD)strlen(g_pszComputerName));
  59. } // GetComputerName
  60. LPSTR STDMETHODCALLTYPE
  61. CInetLogInformation::GetClientHostName(IN PCHAR pszClientHostName,
  62. IN PDWORD pcbSize)
  63. {
  64. return ReturnStringInfo(pszClientHostName,
  65. pcbSize,
  66. m_pLogContext->QueryUlLogData()->ClientIp,
  67. m_pLogContext->QueryUlLogData()->ClientIpLength);
  68. } // GetClientHostName
  69. LPSTR STDMETHODCALLTYPE
  70. CInetLogInformation::GetClientUserName(IN PCHAR pszClientUserName,
  71. IN PDWORD pcbSize)
  72. {
  73. return ReturnStringInfo(pszClientUserName,
  74. pcbSize,
  75. m_strUserName.QueryStr(),
  76. m_strUserName.QueryCCH());
  77. } // GetClientUserName
  78. LPSTR STDMETHODCALLTYPE
  79. CInetLogInformation::GetServerAddress(IN PCHAR pszServerAddress,
  80. IN PDWORD pcbSize)
  81. {
  82. return ReturnStringInfo(pszServerAddress,
  83. pcbSize,
  84. m_pLogContext->QueryUlLogData()->ServerIp,
  85. m_pLogContext->QueryUlLogData()->ServerIpLength);
  86. } // GetServerIPAddress
  87. LPSTR STDMETHODCALLTYPE
  88. CInetLogInformation::GetOperation(IN PCHAR pszOperation,
  89. IN PDWORD pcbSize)
  90. {
  91. return ReturnStringInfo(pszOperation,
  92. pcbSize,
  93. m_pLogContext->QueryUlLogData()->Method,
  94. m_pLogContext->QueryUlLogData()->MethodLength);
  95. } // GetOperation
  96. LPSTR STDMETHODCALLTYPE
  97. CInetLogInformation::GetTarget(IN PCHAR pszTarget,
  98. IN PDWORD pcbSize)
  99. {
  100. return ReturnStringInfo(pszTarget,
  101. pcbSize,
  102. m_strTarget.QueryStr(),
  103. m_strTarget.QueryCCH());
  104. } // GetTarget
  105. LPSTR STDMETHODCALLTYPE
  106. CInetLogInformation::GetParameters(IN PCHAR pszParameters,
  107. IN PDWORD pcbSize)
  108. {
  109. return ReturnStringInfo(pszParameters,
  110. pcbSize,
  111. m_pLogContext->QueryUlLogData()->UriQuery,
  112. m_pLogContext->QueryUlLogData()->UriQueryLength);
  113. } // GetParameters
  114. LPSTR STDMETHODCALLTYPE
  115. CInetLogInformation::GetVersionString(
  116. IN PCHAR pszVersionString,
  117. IN PDWORD pcbSize
  118. )
  119. {
  120. return ReturnStringInfo(pszVersionString,
  121. pcbSize,
  122. m_pLogContext->m_strVersion.QueryStr(),
  123. m_pLogContext->m_strVersion.QueryCCH());
  124. } //GetVersionString
  125. LPSTR STDMETHODCALLTYPE
  126. CInetLogInformation::GetExtraHTTPHeaders(IN PCHAR pszHTTPHeaders,
  127. IN PDWORD pcbSize)
  128. {
  129. return ReturnStringInfo(pszHTTPHeaders,
  130. pcbSize,
  131. m_pLogContext->m_mszHTTPHeaders.QueryStr(),
  132. m_pLogContext->m_mszHTTPHeaders.QueryCCH());
  133. } // GetExtraHTTPHeaders
  134. VOID
  135. CInetLogInformation::CanonicalizeLogRecord(
  136. IN LOG_CONTEXT *pInetLogRecord)
  137. {
  138. m_pLogContext = pInetLogRecord;
  139. HTTP_LOG_FIELDS_DATA *pUlLogData = pInetLogRecord->QueryUlLogData();
  140. if (pUlLogData->UriStem &&
  141. FAILED(m_strTarget.CopyW(pUlLogData->UriStem,
  142. pUlLogData->UriStemLength / sizeof(WCHAR))))
  143. {
  144. m_strTarget.Reset();
  145. }
  146. if (pUlLogData->UserName &&
  147. FAILED(m_strUserName.CopyW(pUlLogData->UserName,
  148. pUlLogData->UserNameLength / sizeof(WCHAR))))
  149. {
  150. m_strUserName.Reset();
  151. }
  152. } // CanonicalizeLogRecord