Source code of Windows XP (NT5)
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.

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