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.

457 lines
14 KiB

  1. /*****************************************************************************\
  2. * *
  3. * storage.h - Definitions for the strutured storage system
  4. * *
  5. * OLE Version 2.0 *
  6. * *
  7. * Copyright (c) 1992-1993, Microsoft Corp. All rights reserved. *
  8. * *
  9. \*****************************************************************************/
  10. #if !defined( _STORAGE_H_ )
  11. #define _STORAGE_H_
  12. #include <compobj.h>
  13. /****** Storage Error Codes *************************************************/
  14. /* DOS-based error codes */
  15. #define STG_E_INVALIDFUNCTION \
  16. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x01)
  17. #define STG_E_FILENOTFOUND \
  18. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x02)
  19. #define STG_E_PATHNOTFOUND \
  20. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x03)
  21. #define STG_E_TOOMANYOPENFILES \
  22. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x04)
  23. #define STG_E_ACCESSDENIED \
  24. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x05)
  25. #define STG_E_INVALIDHANDLE \
  26. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x06)
  27. #define STG_E_INSUFFICIENTMEMORY \
  28. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x08)
  29. #define STG_E_INVALIDPOINTER \
  30. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x09)
  31. #define STG_E_NOMOREFILES \
  32. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x12)
  33. #define STG_E_DISKISWRITEPROTECTED \
  34. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x13)
  35. #define STG_E_SEEKERROR \
  36. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x19)
  37. #define STG_E_WRITEFAULT \
  38. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x1d)
  39. #define STG_E_READFAULT \
  40. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x1e)
  41. #define STG_E_SHAREVIOLATION \
  42. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x20)
  43. #define STG_E_LOCKVIOLATION \
  44. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x21)
  45. #define STG_E_FILEALREADYEXISTS \
  46. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x50)
  47. #define STG_E_INVALIDPARAMETER \
  48. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x57)
  49. #define STG_E_MEDIUMFULL \
  50. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x70)
  51. #define STG_E_ABNORMALAPIEXIT \
  52. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfa)
  53. #define STG_E_INVALIDHEADER \
  54. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfb)
  55. #define STG_E_INVALIDNAME \
  56. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfc)
  57. #define STG_E_UNKNOWN \
  58. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfd)
  59. #define STG_E_UNIMPLEMENTEDFUNCTION\
  60. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xfe)
  61. #define STG_E_INVALIDFLAG \
  62. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0xff)
  63. /* Standard storage error codes */
  64. #define STG_E_INUSE \
  65. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x100)
  66. #define STG_E_NOTCURRENT \
  67. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x101)
  68. #define STG_E_REVERTED \
  69. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x102)
  70. #define STG_E_CANTSAVE \
  71. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x103)
  72. #define STG_E_OLDFORMAT \
  73. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x104)
  74. #define STG_E_OLDDLL \
  75. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x105)
  76. #define STG_E_SHAREREQUIRED \
  77. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x106)
  78. #define STG_E_NOTFILEBASEDSTORAGE \
  79. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x107)
  80. #define STG_E_EXTANTMARSHALLINGS \
  81. MAKE_SCODE(SEVERITY_ERROR, FACILITY_STORAGE, 0x108)
  82. /* Information returns */
  83. #define STG_S_CONVERTED \
  84. MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_STORAGE, 0x200)
  85. /****** Storage types *******************************************************/
  86. #if defined(_M_I286)
  87. typedef char TCHAR;
  88. #ifndef HUGEP
  89. #define HUGEP _huge
  90. #endif
  91. #else
  92. typedef char TCHAR;
  93. #ifndef HUGEP
  94. #define HUGEP
  95. #endif
  96. #endif
  97. #define CWCSTORAGENAME 32
  98. /* Storage instantiation modes */
  99. #define STGM_DIRECT 0x00000000L
  100. #define STGM_TRANSACTED 0x00010000L
  101. #define STGM_READ 0x00000000L
  102. #define STGM_WRITE 0x00000001L
  103. #define STGM_READWRITE 0x00000002L
  104. #define STGM_SHARE_DENY_NONE 0x00000040L
  105. #define STGM_SHARE_DENY_READ 0x00000030L
  106. #define STGM_SHARE_DENY_WRITE 0x00000020L
  107. #define STGM_SHARE_EXCLUSIVE 0x00000010L
  108. #define STGM_PRIORITY 0x00040000L
  109. #define STGM_DELETEONRELEASE 0x04000000L
  110. #define STGM_CREATE 0x00001000L
  111. #define STGM_CONVERT 0x00020000L
  112. #define STGM_FAILIFTHERE 0x00000000L
  113. /* Storage commit types */
  114. typedef enum tagSTGC
  115. {
  116. STGC_DEFAULT = 0,
  117. STGC_OVERWRITE = 1,
  118. STGC_ONLYIFCURRENT = 2,
  119. STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4
  120. } STGC;
  121. /* Stream name block definitions */
  122. typedef char FAR * FAR *SNB;
  123. #ifndef _WINDOWS_
  124. #ifndef _FILETIME_
  125. #define _FILETIME_
  126. typedef struct FARSTRUCT tagFILETIME
  127. {
  128. DWORD dwLowDateTime;
  129. DWORD dwHighDateTime;
  130. } FILETIME;
  131. #endif
  132. #endif
  133. /* Storage stat buffer */
  134. typedef struct FARSTRUCT tagSTATSTG
  135. {
  136. char FAR* pwcsName;
  137. DWORD type;
  138. ULARGE_INTEGER cbSize;
  139. FILETIME mtime;
  140. FILETIME ctime;
  141. FILETIME atime;
  142. DWORD grfMode;
  143. DWORD grfLocksSupported;
  144. CLSID clsid;
  145. DWORD grfStateBits;
  146. DWORD reserved;
  147. } STATSTG;
  148. /* Storage element types */
  149. typedef enum tagSTGTY
  150. {
  151. STGTY_STORAGE = 1,
  152. STGTY_STREAM = 2,
  153. STGTY_LOCKBYTES = 3,
  154. STGTY_PROPERTY = 4
  155. } STGTY;
  156. typedef enum tagSTREAM_SEEK
  157. {
  158. STREAM_SEEK_SET = 0,
  159. STREAM_SEEK_CUR = 1,
  160. STREAM_SEEK_END = 2
  161. } STREAM_SEEK;
  162. typedef enum tagLOCKTYPE
  163. {
  164. LOCK_WRITE = 1,
  165. LOCK_EXCLUSIVE = 2,
  166. LOCK_ONLYONCE = 4
  167. } LOCKTYPE;
  168. typedef enum tagSTGMOVE
  169. {
  170. STGMOVE_MOVE = 0,
  171. STGMOVE_COPY = 1
  172. } STGMOVE;
  173. typedef enum tagSTATFLAG
  174. {
  175. STATFLAG_DEFAULT = 0,
  176. STATFLAG_NONAME = 1
  177. } STATFLAG;
  178. /****** Storage Enumerators *************************************************/
  179. #undef INTERFACE
  180. #define INTERFACE IEnumSTATSTG
  181. DECLARE_INTERFACE_(IEnumSTATSTG, IUnknown)
  182. {
  183. // *** IUnknown methods ***
  184. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  185. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  186. STDMETHOD_(ULONG,Release) (THIS) PURE;
  187. // *** IENUMSTATSTG methods ***
  188. STDMETHOD(Next) (THIS_ ULONG celt, STATSTG FAR * rgelt, ULONG FAR *pceltFetched) PURE;
  189. STDMETHOD(Skip) (THIS_ ULONG celt) PURE;
  190. STDMETHOD(Reset) (THIS) PURE;
  191. STDMETHOD(Clone) (THIS_ IEnumSTATSTG FAR *FAR *ppenm) PURE;
  192. };
  193. typedef IEnumSTATSTG FAR* LPENUMSTATSTG;
  194. /****** ILockBytes Interface ************************************************/
  195. #undef INTERFACE
  196. #define INTERFACE ILockBytes
  197. DECLARE_INTERFACE_(ILockBytes, IUnknown)
  198. {
  199. // *** IUnknown methods ***
  200. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  201. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  202. STDMETHOD_(ULONG,Release) (THIS) PURE;
  203. // *** ILockBytes methods ***
  204. STDMETHOD(ReadAt) (THIS_ ULARGE_INTEGER ulOffset,
  205. VOID HUGEP *pv,
  206. ULONG cb,
  207. ULONG FAR *pcbRead) PURE;
  208. STDMETHOD(WriteAt) (THIS_ ULARGE_INTEGER ulOffset,
  209. VOID const HUGEP *pv,
  210. ULONG cb,
  211. ULONG FAR *pcbWritten) PURE;
  212. STDMETHOD(Flush) (THIS) PURE;
  213. STDMETHOD(SetSize) (THIS_ ULARGE_INTEGER cb) PURE;
  214. STDMETHOD(LockRegion) (THIS_ ULARGE_INTEGER libOffset,
  215. ULARGE_INTEGER cb,
  216. DWORD dwLockType) PURE;
  217. STDMETHOD(UnlockRegion) (THIS_ ULARGE_INTEGER libOffset,
  218. ULARGE_INTEGER cb,
  219. DWORD dwLockType) PURE;
  220. STDMETHOD(Stat) (THIS_ STATSTG FAR *pstatstg, DWORD grfStatFlag) PURE;
  221. };
  222. typedef ILockBytes FAR* LPLOCKBYTES;
  223. /****** IStream Interface ***************************************************/
  224. #undef INTERFACE
  225. #define INTERFACE IStream
  226. DECLARE_INTERFACE_(IStream, IUnknown)
  227. {
  228. // *** IUnknown methods ***
  229. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  230. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  231. STDMETHOD_(ULONG,Release) (THIS) PURE;
  232. // *** IStream methods ***
  233. STDMETHOD(Read) (THIS_ VOID HUGEP *pv,
  234. ULONG cb, ULONG FAR *pcbRead) PURE;
  235. STDMETHOD(Write) (THIS_ VOID const HUGEP *pv,
  236. ULONG cb,
  237. ULONG FAR *pcbWritten) PURE;
  238. STDMETHOD(Seek) (THIS_ LARGE_INTEGER dlibMove,
  239. DWORD dwOrigin,
  240. ULARGE_INTEGER FAR *plibNewPosition) PURE;
  241. STDMETHOD(SetSize) (THIS_ ULARGE_INTEGER libNewSize) PURE;
  242. STDMETHOD(CopyTo) (THIS_ IStream FAR *pstm,
  243. ULARGE_INTEGER cb,
  244. ULARGE_INTEGER FAR *pcbRead,
  245. ULARGE_INTEGER FAR *pcbWritten) PURE;
  246. STDMETHOD(Commit) (THIS_ DWORD grfCommitFlags) PURE;
  247. STDMETHOD(Revert) (THIS) PURE;
  248. STDMETHOD(LockRegion) (THIS_ ULARGE_INTEGER libOffset,
  249. ULARGE_INTEGER cb,
  250. DWORD dwLockType) PURE;
  251. STDMETHOD(UnlockRegion) (THIS_ ULARGE_INTEGER libOffset,
  252. ULARGE_INTEGER cb,
  253. DWORD dwLockType) PURE;
  254. STDMETHOD(Stat) (THIS_ STATSTG FAR *pstatstg, DWORD grfStatFlag) PURE;
  255. STDMETHOD(Clone)(THIS_ IStream FAR * FAR *ppstm) PURE;
  256. };
  257. typedef IStream FAR* LPSTREAM;
  258. /****** IStorage Interface **************************************************/
  259. #undef INTERFACE
  260. #define INTERFACE IStorage
  261. DECLARE_INTERFACE_(IStorage, IUnknown)
  262. {
  263. // *** IUnknown methods ***
  264. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  265. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  266. STDMETHOD_(ULONG,Release) (THIS) PURE;
  267. // *** IStorage methods ***
  268. STDMETHOD(CreateStream) (THIS_ const char FAR* pwcsName,
  269. DWORD grfMode,
  270. DWORD reserved1,
  271. DWORD reserved2,
  272. IStream FAR *FAR *ppstm) PURE;
  273. STDMETHOD(OpenStream) (THIS_ const char FAR* pwcsName,
  274. void FAR *reserved1,
  275. DWORD grfMode,
  276. DWORD reserved2,
  277. IStream FAR *FAR *ppstm) PURE;
  278. STDMETHOD(CreateStorage) (THIS_ const char FAR* pwcsName,
  279. DWORD grfMode,
  280. DWORD reserved1,
  281. DWORD reserved2,
  282. IStorage FAR *FAR *ppstg) PURE;
  283. STDMETHOD(OpenStorage) (THIS_ const char FAR* pwcsName,
  284. IStorage FAR *pstgPriority,
  285. DWORD grfMode,
  286. SNB snbExclude,
  287. DWORD reserved,
  288. IStorage FAR *FAR *ppstg) PURE;
  289. STDMETHOD(CopyTo) (THIS_ DWORD ciidExclude,
  290. IID const FAR *rgiidExclude,
  291. SNB snbExclude,
  292. IStorage FAR *pstgDest) PURE;
  293. STDMETHOD(MoveElementTo) (THIS_ char const FAR* lpszName,
  294. IStorage FAR *pstgDest,
  295. char const FAR* lpszNewName,
  296. DWORD grfFlags) PURE;
  297. STDMETHOD(Commit) (THIS_ DWORD grfCommitFlags) PURE;
  298. STDMETHOD(Revert) (THIS) PURE;
  299. STDMETHOD(EnumElements) (THIS_ DWORD reserved1,
  300. void FAR *reserved2,
  301. DWORD reserved3,
  302. IEnumSTATSTG FAR *FAR *ppenm) PURE;
  303. STDMETHOD(DestroyElement) (THIS_ const char FAR* pwcsName) PURE;
  304. STDMETHOD(RenameElement) (THIS_ const char FAR* pwcsOldName,
  305. const char FAR* pwcsNewName) PURE;
  306. STDMETHOD(SetElementTimes) (THIS_ const char FAR *lpszName,
  307. FILETIME const FAR *pctime,
  308. FILETIME const FAR *patime,
  309. FILETIME const FAR *pmtime) PURE;
  310. STDMETHOD(SetClass) (THIS_ REFCLSID clsid) PURE;
  311. STDMETHOD(SetStateBits) (THIS_ DWORD grfStateBits, DWORD grfMask) PURE;
  312. STDMETHOD(Stat) (THIS_ STATSTG FAR *pstatstg, DWORD grfStatFlag) PURE;
  313. };
  314. typedef IStorage FAR* LPSTORAGE;
  315. /****** IRootStorage Interface **********************************************/
  316. #undef INTERFACE
  317. #define INTERFACE IRootStorage
  318. DECLARE_INTERFACE_(IRootStorage, IUnknown)
  319. {
  320. // *** IUnknown methods ***
  321. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  322. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  323. STDMETHOD_(ULONG,Release) (THIS) PURE;
  324. // *** IRootStorage methods ***
  325. STDMETHOD(SwitchToFile) (THIS_ LPSTR lpstrFile) PURE;
  326. };
  327. typedef IRootStorage FAR* LPROOTSTORAGE;
  328. /****** Storage API Prototypes ********************************************/
  329. STDAPI StgCreateDocfile(const char FAR* pwcsName,
  330. DWORD grfMode,
  331. DWORD reserved,
  332. IStorage FAR * FAR *ppstgOpen);
  333. STDAPI StgCreateDocfileOnILockBytes(ILockBytes FAR *plkbyt,
  334. DWORD grfMode,
  335. DWORD reserved,
  336. IStorage FAR * FAR *ppstgOpen);
  337. STDAPI StgOpenStorage(const char FAR* pwcsName,
  338. IStorage FAR *pstgPriority,
  339. DWORD grfMode,
  340. SNB snbExclude,
  341. DWORD reserved,
  342. IStorage FAR * FAR *ppstgOpen);
  343. STDAPI StgOpenStorageOnILockBytes(ILockBytes FAR *plkbyt,
  344. IStorage FAR *pstgPriority,
  345. DWORD grfMode,
  346. SNB snbExclude,
  347. DWORD reserved,
  348. IStorage FAR * FAR *ppstgOpen);
  349. STDAPI StgIsStorageFile(const char FAR* pwcsName);
  350. STDAPI StgIsStorageILockBytes(ILockBytes FAR* plkbyt);
  351. STDAPI StgSetTimes(char const FAR* lpszName,
  352. FILETIME const FAR* pctime,
  353. FILETIME const FAR* patime,
  354. FILETIME const FAR* pmtime);
  355. #endif