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.

166 lines
4.0 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Config.cpp
  5. Abstract:
  6. This file contains the implementation of the MPCConfig class,
  7. that extends the CISAPIconfig class.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 05/02/99
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. static MPC::wstring l_DefaultInstance = L"DEFAULT";
  14. static DWORD l_MaximumPacketSize = 64*1024;
  15. HRESULT Config_GetInstance( /*[in] */ const MPC::wstring& szURL ,
  16. /*[out]*/ CISAPIinstance*& isapiInstance ,
  17. /*[out]*/ bool& fFound )
  18. {
  19. __ULT_FUNC_ENTRY("Config_GetInstance");
  20. HRESULT hr;
  21. CISAPIconfig::Iter it;
  22. isapiInstance = NULL;
  23. __MPC_EXIT_IF_METHOD_FAILS(hr, g_Config.GetInstance( it, fFound, szURL ));
  24. if(fFound == false)
  25. {
  26. __MPC_EXIT_IF_METHOD_FAILS(hr, g_Config.GetInstance( it, fFound, l_DefaultInstance ));
  27. }
  28. if(fFound)
  29. {
  30. isapiInstance = &(*it);
  31. }
  32. hr = S_OK;
  33. __ULT_FUNC_CLEANUP;
  34. __ULT_FUNC_EXIT(hr);
  35. }
  36. HRESULT Config_GetProvider( /*[in] */ const MPC::wstring& szURL ,
  37. /*[in] */ const MPC::wstring& szName ,
  38. /*[out]*/ CISAPIprovider*& isapiProvider ,
  39. /*[out]*/ bool& fFound )
  40. {
  41. __ULT_FUNC_ENTRY("Config_GetProvider");
  42. HRESULT hr;
  43. CISAPIinstance* isapiInstance;
  44. CISAPIinstance::ProvIter it;
  45. isapiProvider = NULL;
  46. //
  47. // First of all, check if the provider is supplied directly by the instance.
  48. //
  49. __MPC_EXIT_IF_METHOD_FAILS(hr, ::Config_GetInstance( szURL, isapiInstance, fFound ));
  50. if(fFound == false)
  51. {
  52. __MPC_SET_ERROR_AND_EXIT(hr, S_OK);
  53. }
  54. __MPC_EXIT_IF_METHOD_FAILS(hr, isapiInstance->GetProvider( it, fFound, szName ));
  55. if(fFound == false)
  56. {
  57. //
  58. // No, the provider is not provided directly by this instance, try using the DEFAULT one.
  59. //
  60. __MPC_EXIT_IF_METHOD_FAILS(hr, ::Config_GetInstance( l_DefaultInstance, isapiInstance, fFound ));
  61. if(fFound == false)
  62. {
  63. __MPC_SET_ERROR_AND_EXIT(hr, S_OK);
  64. }
  65. __MPC_EXIT_IF_METHOD_FAILS(hr, isapiInstance->GetProvider( it, fFound, szName ));
  66. }
  67. if(fFound)
  68. {
  69. isapiProvider = &((*it).second);
  70. }
  71. hr = S_OK;
  72. __ULT_FUNC_CLEANUP;
  73. __ULT_FUNC_EXIT(hr);
  74. }
  75. HRESULT Config_GetMaximumPacketSize( /*[in] */ const MPC::wstring& szURL ,
  76. /*[out]*/ DWORD& dwMaximumPacketSize )
  77. {
  78. __ULT_FUNC_ENTRY("Config_GetMaximumPacketSize");
  79. HRESULT hr;
  80. CISAPIinstance* isapiInstance;
  81. bool fFound;
  82. dwMaximumPacketSize = l_MaximumPacketSize;
  83. __MPC_EXIT_IF_METHOD_FAILS(hr, ::Config_GetInstance( szURL, isapiInstance, fFound ));
  84. if(fFound)
  85. {
  86. __MPC_EXIT_IF_METHOD_FAILS(hr, isapiInstance->get_MaximumPacketSize( dwMaximumPacketSize ));
  87. }
  88. hr = S_OK;
  89. __ULT_FUNC_CLEANUP;
  90. __ULT_FUNC_EXIT(hr);
  91. }
  92. /////////////////////////////////////////////////////////////////////////////
  93. HRESULT Util_CheckDiskSpace( /*[in] */ const MPC::wstring& szFile ,
  94. /*[in] */ DWORD dwLowLevel ,
  95. /*[out]*/ bool& fEnough )
  96. {
  97. __ULT_FUNC_ENTRY("Util_CheckDiskSpace");
  98. HRESULT hr;
  99. ULARGE_INTEGER liFree;
  100. ULARGE_INTEGER liTotal;
  101. fEnough = false;
  102. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetDiskSpace( szFile, liFree, liTotal ));
  103. if(liFree.HighPart > 0 ||
  104. liFree.LowPart > dwLowLevel )
  105. {
  106. fEnough = true;
  107. }
  108. hr = S_OK;
  109. __ULT_FUNC_CLEANUP;
  110. __ULT_FUNC_EXIT(hr);
  111. }