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.

130 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: simpdf.cxx
  7. //
  8. // Contents: StdDocfile implementation
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 04-Aug-94 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "simphead.cxx"
  18. #pragma hdrstop
  19. #if DBG == 1
  20. DECLARE_INFOLEVEL(simp)
  21. #endif
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Function: DfCreateSimpDocfile, private
  25. //
  26. // Synopsis:
  27. //
  28. // Arguments:
  29. //
  30. // Returns: Appropriate status code
  31. //
  32. // Modifies:
  33. //
  34. // History: 04-Aug-94 PhilipLa Created
  35. //
  36. // Notes:
  37. //
  38. //----------------------------------------------------------------------------
  39. SCODE DfCreateSimpDocfile(WCHAR const *pwcsName,
  40. DWORD grfMode,
  41. DWORD reserved,
  42. IStorage **ppstgOpen)
  43. {
  44. SCODE sc;
  45. CSimpStorage *pstg;
  46. if (ppstgOpen == NULL)
  47. return STG_E_INVALIDPARAMETER;
  48. if (grfMode !=
  49. (STGM_SIMPLE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE))
  50. return STG_E_INVALIDFLAG;
  51. pstg = new CSimpStorage;
  52. if (pstg == NULL)
  53. {
  54. return STG_E_INSUFFICIENTMEMORY;
  55. }
  56. sc = pstg->Init(pwcsName, NULL);
  57. if (FAILED(sc))
  58. {
  59. pstg->Release();
  60. pstg = NULL;
  61. }
  62. *ppstgOpen = pstg;
  63. return sc;
  64. }
  65. #if WIN32 != 200
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Function: DfOpenSimpDocfile, private
  69. //
  70. // Synopsis: opens an existing docfile for reading
  71. //
  72. // Arguments: [pwcsName] name of docfile
  73. // [grfMode] permission bits
  74. // [reserved] must be zero
  75. // [pstgOpen] opened storage pointer
  76. //
  77. // Returns: Appropriate status code
  78. //
  79. // History: 04-Aug-96 HenryLee Created
  80. //
  81. // Notes:
  82. //
  83. //----------------------------------------------------------------------------
  84. SCODE DfOpenSimpDocfile(WCHAR const *pwcsName,
  85. DWORD grfMode,
  86. DWORD reserved,
  87. IStorage **ppstgOpen)
  88. {
  89. SCODE sc = S_OK;
  90. CSimpStorageOpen *pstg;
  91. if (ppstgOpen == NULL)
  92. return STG_E_INVALIDPARAMETER;
  93. else
  94. *ppstgOpen = NULL;
  95. if (grfMode != (STGM_SIMPLE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE) &&
  96. grfMode != (STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE))
  97. return STG_E_INVALIDFLAG;
  98. if ((pstg = new CSimpStorageOpen) == NULL)
  99. {
  100. return STG_E_INSUFFICIENTMEMORY;
  101. }
  102. if (FAILED(sc = pstg->Init(pwcsName, grfMode, NULL)))
  103. {
  104. pstg->Release();
  105. pstg = NULL;
  106. }
  107. *ppstgOpen = pstg;
  108. return sc;
  109. }
  110. #endif // WIN32 != 200