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.

198 lines
6.6 KiB

  1. //+-------------------------------------------------------------------------
  2. // Microsoft OLE
  3. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  4. // All rights reserved.
  5. //
  6. // File: stgwrap.hxx
  7. //
  8. // Contents: Wrapper for StgOpen/Create apis
  9. //
  10. // Notes: Wrap the StgOpen/Create apis
  11. // This is to permit nssfile and conversion testing
  12. // using the same codebase as the docfile tests with
  13. // minimal changes to that codebase.
  14. // This is probably only good while the different
  15. // ole apis give different storage types.
  16. //
  17. // NOTE: To turn on nss/cnv functionality you must add
  18. // -D_OLE_NSS_ -D_HOOK_STGAPI_ to you C_DEFINES
  19. // in daytona.mk
  20. //
  21. // History: SCousens 24-Feb-97 Created
  22. //--------------------------------------------------------------------------
  23. #ifndef ARRAYSIZE
  24. #define ARRAYSIZE(ar) sizeof(ar)/sizeof(ar[0])
  25. #endif
  26. // type of storage for the tests
  27. typedef enum _tagTSTTYPE
  28. {
  29. TSTTYPE_DEFAULT = 0, // use default, dont muck about
  30. TSTTYPE_DOCFILE = 1, // force docfile operation with new api
  31. TSTTYPE_NSSFILE = 2, // force nssfile operation with new api
  32. TSTTYPE_FLATFILE, // force flatfile storage
  33. } TSTTYPE;
  34. enum
  35. {
  36. REG_OPEN_AS = 1,
  37. REG_CREATE_AS = 2,
  38. REG_CNSS_ENABLE = 4
  39. };
  40. typedef enum _tagDSKSTG
  41. {
  42. DSKSTG_DEFAULT = 0,
  43. DSKSTG_DOCFILE = 1,
  44. DSKSTG_NSSFILE = 2,
  45. } DSKSTG;
  46. #define SZ_DOCFILE "docfile"
  47. #define SZ_NSSFILE "nssfile"
  48. #define SZ_FLATFILE "flatfile"
  49. //#define SZ_CONVERSION "conversion"
  50. #define SZ_DEFAULT "default"
  51. #define SZ_LARGE "large"
  52. #define TSZ_DOCFILE TEXT(SZ_DOCFILE)
  53. #define TSZ_NSSFILE TEXT(SZ_NSSFILE)
  54. #define TSZ_FLATFILE TEXT(SZ_FLATFILE)
  55. //#define TSZ_CONVERSION TEXT(SZ_CONVERSION)
  56. // These functions are used by the tests and common code to
  57. // determine which apis to call (where necessary) to get nssfiles
  58. // or docfiles. This will change as the ole32.dll behaviour changes,
  59. // but this way the changes are limited to the common code only, not
  60. // each test.
  61. // The ONLY change to the tests should be a call to InitStgWrapper
  62. // with the commandline so that the wrapper can determine whether
  63. // it is supposed to be doing nss or cnv or df testing.
  64. #ifdef _OLE_NSS_
  65. BOOL StgInitStgFormatWrapper (int argc, char *argv[]);
  66. BOOL StgInitStgFormatWrapper (TCHAR *pCreateType, TCHAR *pOpenType);
  67. extern TSTTYPE g_uCreateType;
  68. extern TSTTYPE g_uOpenType;
  69. extern DWORD g_fRegistryBits;
  70. // These macros look at the cmdline and the registry to determine the correct answer.
  71. // They do not distinguish between forcing the issue via cmdline or using default in the registry.
  72. inline BOOL DoingCreateNssfile()
  73. {
  74. return (BOOL)(TSTTYPE_NSSFILE == g_uCreateType ||
  75. TSTTYPE_DEFAULT == g_uCreateType && (REG_CREATE_AS & g_fRegistryBits)) ?
  76. TRUE : FALSE;
  77. }
  78. inline BOOL DoingOpenNssfile()
  79. {
  80. return (BOOL)(TSTTYPE_NSSFILE == g_uOpenType ||
  81. TSTTYPE_DEFAULT == g_uOpenType && (REG_OPEN_AS & g_fRegistryBits)) ?
  82. TRUE : FALSE;
  83. }
  84. // creating nssfile and opening docfile
  85. inline BOOL DoingConversion() {return (BOOL)(DoingCreateNssfile() && !DoingOpenNssfile());}
  86. // check if we are testing flatfile NTFS storage
  87. inline BOOL StorageIsFlat()
  88. {
  89. return (TSTTYPE_FLATFILE == g_uCreateType ||
  90. TSTTYPE_FLATFILE == g_uOpenType);
  91. }
  92. #else // _OLE_NSS_
  93. #define StgInitStgFormatWrapper(a,b) 1
  94. #define DoingCreateNssfile() 0
  95. #define DoingOpenNssfile() 0
  96. #define DoingConversion() 0
  97. // check if we are testing flatfile NTFS storage
  98. inline BOOL StorageIsFlat() { return FALSE; };
  99. #endif // _OLE_NSS_
  100. //*********************************************************/
  101. //
  102. // Conversion/NSS hacks
  103. //
  104. //*********************************************************/
  105. #ifdef _OLE_NSS_
  106. /* only hook if we are not doing vanilla docfile testing */
  107. #ifdef _HOOK_STGAPI_
  108. // hook the stgcreatedocfile stgopenstorage apis
  109. #define StgCreateDocfile mStgCreateDocfile
  110. #define StgOpenStorage mStgOpenStorage
  111. HRESULT mStgCreateDocfile(const OLECHAR FAR* pwcsName,
  112. DWORD grfMode,
  113. DWORD reserved,
  114. IStorage FAR * FAR *ppstgOpen);
  115. HRESULT mStgOpenStorage (const OLECHAR FAR* pwcsName,
  116. IStorage FAR *pstgPriority,
  117. DWORD grfMode,
  118. SNB snbExclude,
  119. DWORD reserved,
  120. IStorage FAR * FAR *ppstgOpen);
  121. #endif /* _HOOK_STGAPI_ */
  122. // our tests use STGFMT_GENERIC for stgfmt, which should
  123. // equate to 0. That will be the required value for this release.
  124. #define STGFMT_GENERIC STGFMT_DOCUMENT
  125. #else // _OLE_NSS_
  126. // New Stg*Ex apis are not available (or we dont want to use them),
  127. // so make sure our calls to them use the old apis.
  128. // NOTE: This hack should be to enable a link. The code should not
  129. // actually get to these calls when doing docfile tests.
  130. #define STGFMT_GENERIC 0
  131. #define STGFMT DWORD //ouch. major hack!
  132. #define StgCreateStorageEx(pwcsName, \
  133. grfMode, \
  134. dwstgfmt, \
  135. grfAttrs, \
  136. pSecurity, \
  137. pTransaction, \
  138. riid, \
  139. ppObjectOpen) \
  140. StgCreateDocfile(pwcsName, \
  141. grfMode, \
  142. NULL, \
  143. (IStorage**)ppObjectOpen)
  144. #define StgOpenStorageEx(pwcsName, \
  145. grfMode, \
  146. dwstgfmt, \
  147. grfAttrs, \
  148. pSecurity, \
  149. pTransaction, \
  150. riid, \
  151. ppObjectOpen) \
  152. StgOpenStorage(pwcsName, \
  153. NULL, \
  154. grfMode, \
  155. NULL, \
  156. NULL, \
  157. (IStorage**)ppObjectOpen)
  158. // people calling the wrapper directly - map to old apis
  159. #define mStgCreateDocfile StgCreateDocfile
  160. #define mStgOpenStorage StgOpenStorage
  161. #endif // _OLE_NSS_ // Stg*Ex api hacks