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.

109 lines
2.7 KiB

  1. // RestPars.cxx : Implementation of CRestoreParser
  2. #include "pch.cxx"
  3. #pragma hdrstop
  4. #include <trklib.hxx>
  5. #include <trksvr.hxx>
  6. #include "stdafx.h"
  7. #include "ITrkAdmn.h"
  8. #include "restore.h"
  9. #include "RestPars.hxx"
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CRestoreParser
  12. HRESULT STDMETHODCALLTYPE
  13. CRestoreParser::ParseDisplayName(
  14. /* [unique][in] */ IBindCtx __RPC_FAR *pbc,
  15. /* [in] */ LPOLESTR poszDisplayName,
  16. /* [out] */ ULONG __RPC_FAR *pchEaten,
  17. /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut)
  18. {
  19. LPOLESTR poszTmp = poszDisplayName;
  20. HRESULT hr = E_INVALIDARG;
  21. *ppmkOut = static_cast<IMoniker*>(this);
  22. *pchEaten = ocslen(poszDisplayName);
  23. (*ppmkOut)->AddRef();
  24. if(TEXT('@') != poszTmp[0])
  25. {
  26. TrkLog((TRKDBG_ERROR, TEXT("Unrecognized display name (%s)"),
  27. poszDisplayName));
  28. goto Exit;
  29. }
  30. poszTmp++;
  31. poszTmp = _tcschr(poszTmp, TEXT('@'));
  32. if(TEXT('\0') == poszTmp)
  33. {
  34. TrkLog((TRKDBG_ERROR, TEXT("Unrecognized progid in display name (%s)"),
  35. poszDisplayName));
  36. goto Exit;
  37. }
  38. poszTmp++;
  39. if(TEXT('\0') == poszTmp)
  40. {
  41. TrkLog((TRKDBG_ERROR, TEXT("Unexpected end of display name (%s)"),
  42. poszDisplayName));
  43. goto Exit;
  44. }
  45. __try
  46. {
  47. _mcid = CMachineId(poszTmp);
  48. hr = S_OK;
  49. }
  50. __except(EXCEPTION_EXECUTE_HANDLER)
  51. {
  52. TrkLog((TRKDBG_ERROR, TEXT("Can't convert \"%s\" to machine id"),
  53. poszTmp));
  54. hr = GetExceptionCode();
  55. goto Exit;
  56. }
  57. Exit:
  58. return(hr);
  59. }
  60. /* [local] */ HRESULT STDMETHODCALLTYPE
  61. CRestoreParser::BindToObject(
  62. /* [unique][in] */ IBindCtx __RPC_FAR *pbc,
  63. /* [unique][in] */ IMoniker __RPC_FAR *pmkToLeft,
  64. /* [in] */ REFIID riidResult,
  65. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvResult)
  66. {
  67. HRESULT hr = E_FAIL;
  68. IClassFactory *pCF = NULL;
  69. hr = _Module.GetClassObject(CLSID_TrkRestoreNotify, IID_IClassFactory,
  70. reinterpret_cast<void**>(&pCF) );
  71. if( FAILED(hr) )
  72. {
  73. TrkLog(( TRKDBG_ERROR, TEXT("Couldn't get ClassFactory in CRestoreParser::BindTobObject (%08x)"), hr ));
  74. goto Exit;
  75. }
  76. hr = pCF->CreateInstance( NULL, riidResult, ppvResult );
  77. if( FAILED(hr) )
  78. {
  79. TrkLog(( TRKDBG_ERROR, TEXT("Couldn't createinstance in CRestoreParser (%08x)"), hr ));
  80. goto Exit;
  81. }
  82. reinterpret_cast<CTrkRestoreNotify*>(*ppvResult)->SetMachine(_mcid);
  83. hr = S_OK;
  84. Exit:
  85. RELEASE_INTERFACE( pCF );
  86. return( hr );
  87. }