Source code of Windows XP (NT5)
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.

193 lines
3.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: Supp.cxx
  7. //
  8. // Contents: Supplementary classes
  9. //
  10. // Classes: CModeDf - Docfile creation modes
  11. //
  12. // History: 25-Jan-93 AlexT Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <sift.hxx>
  18. #if DBG != 1
  19. #error FAIL.EXE requires DBG == 1
  20. #endif
  21. // #define DEPTHTEST // Uncomment out for depth testing (long time)
  22. //+-------------------------------------------------------------------------
  23. //
  24. // Notes: Mode combinations for StgCreateDocfile
  25. //
  26. //--------------------------------------------------------------------------
  27. DWORD adwTransactionModes[] = {
  28. STGM_DIRECT,
  29. STGM_TRANSACTED
  30. };
  31. #define TMODES (sizeof(adwTransactionModes) / sizeof(DWORD))
  32. DWORD adwAccessModes[] = {
  33. STGM_READWRITE,
  34. STGM_WRITE,
  35. STGM_READ
  36. };
  37. #if defined(DEPTHTEST)
  38. # define AMODES (sizeof(adwAccessModes) / sizeof(DWORD))
  39. #else
  40. # define AMODES 1
  41. #endif
  42. DWORD adwShareModes[] = {
  43. STGM_SHARE_DENY_NONE,
  44. STGM_SHARE_EXCLUSIVE,
  45. STGM_SHARE_DENY_READ,
  46. STGM_SHARE_DENY_WRITE
  47. };
  48. #if defined(DEPTHTEST)
  49. # define SMODES (sizeof(adwShareModes) / sizeof(DWORD))
  50. #else
  51. # define SMODES 2
  52. #endif
  53. DWORD adwDeleteModes[] = {
  54. 0,
  55. STGM_DELETEONRELEASE
  56. };
  57. #if defined(DEPTHTEST)
  58. # define DMODES (sizeof(adwDeleteModes) / sizeof(DWORD))
  59. #else
  60. # define DMODES 1
  61. #endif
  62. DWORD adwCreateModes[] = {
  63. STGM_FAILIFTHERE,
  64. STGM_CREATE,
  65. STGM_CONVERT
  66. };
  67. #if defined(DEPTHTEST)
  68. # define CMODES (sizeof(adwCreateModes) / sizeof(DWORD))
  69. #else
  70. # define CMODES 1
  71. #endif
  72. void CModeDf::Init(void)
  73. {
  74. _it = _ia = _is = _id = _ic = 0;
  75. CalcMode();
  76. }
  77. void CModeDf::CalcMode(void)
  78. {
  79. _dwMode = adwTransactionModes[_it] |
  80. adwAccessModes[_ia] |
  81. adwShareModes[_is] |
  82. adwDeleteModes[_id] |
  83. adwCreateModes[_ic];
  84. }
  85. BOOL CModeDf::Next(void)
  86. {
  87. BOOL f = TRUE;
  88. if (++_ic >= CMODES)
  89. {
  90. _ic = 0;
  91. if (++_id >= DMODES)
  92. {
  93. _id = 0;
  94. if (++_is >= SMODES)
  95. {
  96. _is = 0;
  97. if (++_ia >= AMODES)
  98. {
  99. _ia = 0;
  100. if (++_it >= TMODES)
  101. {
  102. f = FALSE;
  103. }
  104. }
  105. }
  106. }
  107. }
  108. if (f)
  109. CalcMode();
  110. return(f);
  111. }
  112. void CModeStg::Init(void)
  113. {
  114. _it = _ia = 0;
  115. CalcMode();
  116. }
  117. void CModeStg::CalcMode(void)
  118. {
  119. _dwMode = adwTransactionModes[_it] |
  120. adwAccessModes[_ia] |
  121. STGM_SHARE_EXCLUSIVE;
  122. }
  123. BOOL CModeStg::Next(void)
  124. {
  125. BOOL f = TRUE;
  126. if (++_ia >= AMODES)
  127. {
  128. _ia = 0;
  129. if (++_it >= TMODES)
  130. {
  131. f = FALSE;
  132. }
  133. }
  134. if (f)
  135. CalcMode();
  136. return(f);
  137. }
  138. void CModeStm::Init(void)
  139. {
  140. _ia = 0;
  141. CalcMode();
  142. }
  143. void CModeStm::CalcMode(void)
  144. {
  145. _dwMode = STGM_DIRECT |
  146. adwAccessModes[_ia] |
  147. STGM_SHARE_EXCLUSIVE;
  148. }
  149. BOOL CModeStm::Next(void)
  150. {
  151. BOOL f = TRUE;
  152. if (++_ia >= AMODES)
  153. {
  154. f = FALSE;
  155. }
  156. if (f)
  157. CalcMode();
  158. return(f);
  159. }