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.

449 lines
14 KiB

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