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.

134 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: asyncapi.cxx
  7. //
  8. // Contents: APIs for async docfiles
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 19-Dec-95 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "astghead.cxx"
  18. #pragma hdrstop
  19. #include "asyncapi.hxx"
  20. #include "filllkb.hxx"
  21. #include "filelkb.hxx"
  22. #include "stgwrap.hxx"
  23. #if DBG == 1
  24. DECLARE_INFOLEVEL(astg);
  25. #endif
  26. HRESULT StgOpenAsyncDocfileOnIFillLockBytes( IFillLockBytes *pflb,
  27. DWORD grfMode,
  28. DWORD asyncFlags,
  29. IStorage **ppstgOpen)
  30. {
  31. HRESULT hr;
  32. ILockBytes *pilb;
  33. IStorage *pstg;
  34. hr = pflb->QueryInterface(IID_ILockBytes, (void **)&pilb);
  35. if (FAILED(hr))
  36. {
  37. return hr;
  38. }
  39. hr = StgOpenStorageOnILockBytes(pilb,
  40. NULL,
  41. grfMode,
  42. NULL,
  43. 0,
  44. &pstg);
  45. pilb->Release();
  46. if (FAILED(hr))
  47. {
  48. return hr;
  49. }
  50. *ppstgOpen = new CAsyncRootStorage(pstg,(CFillLockBytes *) pflb);
  51. if (*ppstgOpen == NULL)
  52. {
  53. return STG_E_INSUFFICIENTMEMORY;
  54. }
  55. return NOERROR;
  56. }
  57. HRESULT StgGetIFillLockBytesOnILockBytes( ILockBytes *pilb,
  58. IFillLockBytes **ppflb)
  59. {
  60. SCODE sc = S_OK;
  61. CFillLockBytes *pflb = NULL;
  62. pflb = new CFillLockBytes(pilb);
  63. if (pflb == NULL)
  64. {
  65. return STG_E_INSUFFICIENTMEMORY;
  66. }
  67. sc = pflb->Init();
  68. if (FAILED(sc))
  69. {
  70. *ppflb = NULL;
  71. return sc;
  72. }
  73. *ppflb = pflb;
  74. return NOERROR;
  75. }
  76. HRESULT StgGetIFillLockBytesOnFile(OLECHAR const *pwcsName,
  77. IFillLockBytes **ppflb)
  78. {
  79. SCODE sc;
  80. CFileLockBytes *pflb = NULL;
  81. pflb = new CFileLockBytes;
  82. if (pflb == NULL)
  83. {
  84. return STG_E_INSUFFICIENTMEMORY;
  85. }
  86. sc = pflb->Init(pwcsName);
  87. if (SUCCEEDED(sc))
  88. {
  89. sc = StgGetIFillLockBytesOnILockBytes(pflb, ppflb);
  90. }
  91. return sc;
  92. }
  93. #if DBG == 1
  94. HRESULT StgGetDebugFileLockBytes(OLECHAR const *pwcsName, ILockBytes **ppilb)
  95. {
  96. SCODE sc;
  97. CFileLockBytes *pflb;
  98. *ppilb = NULL;
  99. pflb = new CFileLockBytes;
  100. if (pflb == NULL)
  101. {
  102. return STG_E_INSUFFICIENTMEMORY;
  103. }
  104. sc = pflb->Init(pwcsName);
  105. if (FAILED(sc))
  106. {
  107. delete pflb;
  108. pflb = NULL;
  109. }
  110. *ppilb = pflb;
  111. return sc;
  112. }
  113. #endif