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.

94 lines
2.4 KiB

  1. /*
  2. * C V R O O T . C P P
  3. *
  4. * Cached vroot information
  5. *
  6. * Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  7. */
  8. #include <_vroot.h>
  9. DEC_CONST WCHAR gc_wszPort80[] = L":80";
  10. DEC_CONST UINT gc_cchPort80 = CchConstString(gc_wszPort80);
  11. DEC_CONST WCHAR gc_wszPort443[] = L":443";
  12. DEC_CONST UINT gc_cchPort443 = CchConstString(gc_wszPort443);
  13. // CVRoot --------------------------------------------------------------------
  14. //
  15. CVRoot::CVRoot(
  16. /* [in] */ LPCWSTR pwszMetaUrl,
  17. /* [in] */ UINT cchMetaUrlPrefix,
  18. /* [in] */ UINT cchServerDefault,
  19. /* [in] */ LPCWSTR pwszServerDefault,
  20. /* [in] */ IMDData* pMDData ) :
  21. m_pMDData(pMDData),
  22. m_pwszMbPath(m_sb.AppendWithNull(pwszMetaUrl)),
  23. m_pwszServer(pwszServerDefault), // Static from CChildVRCache
  24. m_cchServer(cchServerDefault),
  25. m_pwszPort(gc_wszPort80),
  26. m_cchPort(gc_cchPort80),
  27. m_fSecure(FALSE),
  28. m_fDefaultPort(TRUE)
  29. {
  30. LPCWSTR pwsz;
  31. LPCWSTR pwszPort;
  32. // Find the vroot in the metabase path
  33. //
  34. Assert (cchMetaUrlPrefix <= static_cast<UINT>(wcslen(m_pwszMbPath)));
  35. m_pwszVRoot = m_pwszMbPath + cchMetaUrlPrefix;
  36. m_cchVRoot = static_cast<UINT>(wcslen(m_pwszVRoot));
  37. // Make a wide copy of the physical path
  38. //
  39. Assert (pMDData->PwszVRPath());
  40. pwsz = pMDData->PwszVRPath();
  41. m_cchVRPath = static_cast<UINT>(wcslen(pwsz));
  42. m_pwszVRPath = static_cast<LPWSTR>(g_heap.Alloc(CbSizeWsz(m_cchVRPath)));
  43. memcpy(m_pwszVRPath, pwsz, CbSizeWsz(m_cchVRPath));
  44. // Process the server information out of the server bindings
  45. //
  46. if (NULL != (pwsz = pMDData->PwszBindings()))
  47. {
  48. Assert (pwsz);
  49. pwszPort = wcschr (pwsz, L':');
  50. // If there was no leading server name, then get the default
  51. // server name for the machine
  52. //
  53. if (pwsz != pwszPort)
  54. {
  55. // A specific name was specified, so use that instead of
  56. // the default
  57. //
  58. m_cchServer = static_cast<UINT>(pwszPort - pwsz);
  59. m_pwszServer = pwsz;
  60. }
  61. // For the port, trim off the trailing ":xxx"
  62. //
  63. if (NULL != (pwsz = wcschr (pwszPort + 1, L':')))
  64. {
  65. m_cchPort = static_cast<UINT>(pwsz - pwszPort);
  66. m_pwszPort = pwszPort;
  67. if ((gc_cchPort80 != m_cchPort) ||
  68. wcsncmp (m_pwszPort,
  69. gc_wszPort80,
  70. gc_cchPort80))
  71. {
  72. m_fDefaultPort = FALSE;
  73. }
  74. if ((gc_cchPort443 == m_cchPort) &&
  75. !wcsncmp (m_pwszPort,
  76. gc_wszPort443,
  77. gc_cchPort443))
  78. {
  79. m_fSecure = TRUE;
  80. }
  81. }
  82. }
  83. }