Commit d92b9475 authored by Francis Beaudet's avatar Francis Beaudet Committed by Alexandre Julliard

Added an implementation of the OLE structured storage. The main

features of this implementation are: - Can open storages created in Windows. - Can create new storages that the windows libraries can read. - Provides all the functionality to create/open/remove and rename streams and storages inside the main storage object.
parent b77de029
......@@ -93,6 +93,30 @@ DECL_WINELIB_TYPE(LPSTREAM)
#define STGM_NOSCRATCH 0x00100000
#define STGM_NOSNAPSHOT 0x00200000
/*****************************************************************************
* STGTY enumeration
*
* See IStorage
*/
#define STGTY_STORAGE 1
#define STGTY_STREAM 2
/*****************************************************************************
* STATFLAG enumeration
*
* See IStorage and IStream
*/
#define STATFLAG_DEFAULT 0
#define STATFLAG_NONAME 1
/*****************************************************************************
* STREAM_SEEK enumeration
*
* See IStream
*/
#define STREAM_SEEK_SET 0
#define STREAM_SEEK_CUR 1
#define STREAM_SEEK_END 2
/*****************************************************************************
* STATSTG structure
......@@ -115,8 +139,26 @@ struct STATSTG {
/*****************************************************************************
* IEnumSTATSTG interface
*/
/* FIXME: not implemented */
#define ICOM_INTERFACE IEnumSTATSTG
ICOM_BEGIN(IEnumSTATSTG,IUnknown)
ICOM_METHOD3(HRESULT, Next, ULONG, celt, STATSTG*, rgelt, ULONG*, pceltFetched);
ICOM_METHOD1(HRESULT, Skip, ULONG, celt);
ICOM_CMETHOD(HRESULT, Reset);
ICOM_METHOD1(HRESULT, Clone, IEnumSTATSTG**, ppenum);
ICOM_END(IEnumSTATSTG)
#undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IEnumSTATSTG_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
#define IEnumSTATSTG_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p)
#define IEnumSTATSTG_Release(p) ICOM_ICALL (IUnknown,Release,p)
/*** IEnumSTATSTG methods ***/
#define IEnumSTATSTG_Next(p,a,b,c) ICOM_CALL3(Next,p,a,b,c)
#define IEnumSTATSTG_Skip(p,a) ICOM_CALL1(Skip,p,a)
#define IEnumSTATSTG_Reset(p) ICOM_CALL(Reset,p)
#define IEnumSTATSTG_Clone(p,a) ICOM_CALL1(Clone,p,a)
#endif
/*****************************************************************************
* IFillLockBytes interface
......@@ -426,8 +468,8 @@ ICOM_END(IStream32)
#define IStream32_Read(p,a,b,c) ICOM_ICALL3(ISequentialStream,Read,p,a,b,c)
#define IStream32_Write(p,a,b,c) ICOM_ICALL3(ISequentialStream,Write,p,a,b,c)
/*** IStream32 methods ***/
#define IStream32_Seek(p) ICOM_CALL3(Seek,p)
#define IStream32_SetSize(p,a,b) ICOM_CALL1(SetSize,p,a,b)
#define IStream32_Seek(p,a,b,c) ICOM_CALL3(Seek,p,a,b,c)
#define IStream32_SetSize(p,a) ICOM_CALL1(SetSize,p,a)
#define IStream32_CopyTo(pa,b,c,d) ICOM_CALL4(CopyTo,pa,b,c,d)
#define IStream32_Commit(p,a) ICOM_CALL1(Commit,p,a)
#define IStream32_Revert(p) ICOM_CALL (Revert,p)
......@@ -446,8 +488,8 @@ ICOM_END(IStream32)
#define IStream_Read(p,a,b,c) ICOM_ICALL3(ISequentialStream,Read,p,a,b,c)
#define IStream_Write(p,a,b,c) ICOM_ICALL3(ISequentialStream,Write,p,a,b,c)
/*** IStream methods ***/
#define IStream_Seek(p) ICOM_CALL3(Seek,p)
#define IStream_SetSize(p,a,b) ICOM_CALL1(SetSize,p,a,b)
#define IStream_Seek(p,a,b,c) ICOM_CALL3(Seek,p,a,b,c)
#define IStream_SetSize(p,a) ICOM_CALL1(SetSize,p,a)
#define IStream_CopyTo(pa,b,c,d) ICOM_CALL4(CopyTo,pa,b,c,d)
#define IStream_Commit(p,a) ICOM_CALL1(Commit,p,a)
#define IStream_Revert(p) ICOM_CALL (Revert,p)
......@@ -475,6 +517,7 @@ HRESULT WINAPI StgOpenStorage16(const OLECHAR16* pwcsName,IStorage16* pstgPriori
HRESULT WINAPI StgOpenStorage32(const OLECHAR32* pwcsName,IStorage32* pstgPriority,DWORD grfMode,SNB32 snbExclude,DWORD reserved,IStorage32**ppstgOpen);
#define StgOpenStorage WINELIB_NAME(StgOpenStorage)
HRESULT WINAPI WriteClassStg32(IStorage32* pStg, REFCLSID rclsid);
#define WriteClassStg WINELIB_NAME(WriteClassStg)
#endif /* __WINE_WINE_OBJ_STORAGE_H */
......@@ -23,6 +23,9 @@ C_SRCS = \
parsedt.c \
safearray.c \
storage.c \
storage32.c \
stg_bigblockfile.c \
stg_stream.c \
typelib.c \
variant.c
......
......@@ -66,10 +66,8 @@ static const BYTE STORAGE_oldmagic[8]={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d};
#define READ_HEADER assert(STORAGE_get_big_block(hf,-1,(LPBYTE)&sth));assert(!memcmp(STORAGE_magic,sth.magic,sizeof(STORAGE_magic)));
static ICOM_VTABLE(IStorage16) stvt16;
static ICOM_VTABLE(IStorage16) *segstvt16 = NULL;
static ICOM_VTABLE(IStorage32) stvt32;
static ICOM_VTABLE(IStream16) strvt16;
static ICOM_VTABLE(IStream16) *segstrvt16 = NULL;
static ICOM_VTABLE(IStream32) strvt32;
/*ULONG WINAPI IStorage16_AddRef(LPSTORAGE16 this);*/
static void _create_istorage16(LPSTORAGE16 *stg);
......@@ -1211,25 +1209,6 @@ ULONG WINAPI IStream32_fnRelease(LPUNKNOWN iface) {
return this->ref;
}
static ICOM_VTABLE(IStream32) strvt32 = {
{
{
IStream32_fnQueryInterface,
IStream32_fnAddRef,
IStream32_fnRelease
},
(void*)0xdead0004,
(void*)0xdead0005
},
(void*)0xdead0006,
(void*)0xdead0007,
(void*)0xdead0008,
(void*)0xdead0009,
(void*)0xdead0010,
(void*)0xdead0011
};
/* --- IStorage16 implementation */
typedef struct _IStorage16 {
......@@ -1591,114 +1570,6 @@ static void _create_istorage16(LPSTORAGE16 *stg) {
*stg = (void*)lpst->thisptr;
}
/* --- IStorage32 implementation */
typedef struct _IStorage32 {
/* IUnknown fields */
ICOM_VTABLE(IStorage32)* lpvtbl;
DWORD ref;
/* IStorage32 fields */
struct storage_pps_entry stde;
int ppsent;
HFILE32 hf;
} _IStorage32;
/******************************************************************************
* IStorage32_QueryInterface [VTABLE]
*/
HRESULT WINAPI IStorage32_fnQueryInterface(
LPUNKNOWN iface,REFIID refiid,LPVOID *obj
) {
ICOM_THIS(IStorage32,iface);
char xrefiid[50];
WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
TRACE(relay,"(%p)->(%s,%p)\n",this,xrefiid,obj);
if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
*obj = this;
return 0;
}
return OLE_E_ENUM_NOMORE;
}
/******************************************************************************
* IStorage32_AddRef [VTABLE]
*/
ULONG WINAPI IStorage32_fnAddRef(LPUNKNOWN iface) {
ICOM_THIS(IStorage32,iface);
return ++(this->ref);
}
/******************************************************************************
* IStorage32_Release [VTABLE]
*/
ULONG WINAPI IStorage32_fnRelease(LPUNKNOWN iface) {
ICOM_THIS(IStorage32,iface);
this->ref--;
if (this->ref)
return this->ref;
HeapFree(GetProcessHeap(),0,this);
return 0;
}
/******************************************************************************
* IStorage32_CreateStream [VTABLE]
*/
HRESULT WINAPI IStorage32_fnCreateStream(
LPSTORAGE32 iface,LPCOLESTR32 pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2, IStream32 **ppstm
) {
ICOM_THIS(IStorage32,iface);
TRACE(ole,"(%p)->(%p,0x%08lx,0x%08lx,0x%08lx,%p)\n",
this,pwcsName,grfMode,reserved1,reserved2,ppstm
);
*ppstm = (IStream32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStream32));
((_IStream32*)(*ppstm))->lpvtbl= &strvt32;
((_IStream32*)(*ppstm))->ref = 1;
return S_OK;
}
/******************************************************************************
* IStorage32_OpenStream [VTABLE]
*/
HRESULT WINAPI IStorage32_fnOpenStream(
LPSTORAGE32 iface,LPCOLESTR32 pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream32 **ppstm
) {
ICOM_THIS(IStorage32,iface);
TRACE(ole,"(%p)->(%p,%p,0x%08lx,0x%08lx,%p)\n",
this,pwcsName,reserved1,grfMode,reserved2,ppstm
);
*ppstm = (IStream32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStream32));
((_IStream32*)(*ppstm))->lpvtbl= &strvt32;
((_IStream32*)(*ppstm))->ref = 1;
return S_OK;
}
static ICOM_VTABLE(IStorage32) stvt32 = {
{
IStorage32_fnQueryInterface,
IStorage32_fnAddRef,
IStorage32_fnRelease
},
IStorage32_fnCreateStream,
IStorage32_fnOpenStream,
(void*)0xdead0006,
(void*)0xdead0007,
(void*)0xdead0008,
(void*)0xdead0009,
(void*)0xdead0010,
(void*)0xdead0011,
(void*)0xdead0012,
(void*)0xdead0013,
(void*)0xdead0014,
(void*)0xdead0015,
(void*)0xdead0016,
(void*)0xdead0017,
(void*)0xdead0018,
};
/******************************************************************************
* Storage API functions
*/
......@@ -1744,21 +1615,7 @@ HRESULT WINAPI StgCreateDocFile16(
IStorage16_fnRelease((IUnknown*)lpstg); /* will remove it */
return E_FAIL;
}
return S_OK;
}
/******************************************************************************
* StgCreateDocfile32 [OLE32.144]
*/
HRESULT WINAPI StgCreateDocfile32(
LPCOLESTR32 pwcsName,DWORD grfMode,DWORD reserved,IStorage32 **ppstgOpen
) {
TRACE(ole,"(%p,0x%08lx,0x%08lx,%p)\n",
pwcsName,grfMode,reserved,ppstgOpen
);
*ppstgOpen = (IStorage32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStorage32));
((_IStorage32*)(*ppstgOpen))->ref = 1;
((_IStorage32*)(*ppstgOpen))->lpvtbl = &stvt32;
return S_OK;
}
......@@ -1854,20 +1711,4 @@ HRESULT WINAPI StgOpenStorage16(
}
/******************************************************************************
* StgOpenStorage32 [OLE32.148]
*/
HRESULT WINAPI StgOpenStorage32(
const OLECHAR32 * pwcsName,IStorage32 *pstgPriority,DWORD grfMode,
SNB32 snbExclude,DWORD reserved, IStorage32 **ppstgOpen
) {
FIXME(ole,"StgOpenStorage32(%p,%p,0x%08lx,%p,%ld,%p),stub!\n",
pwcsName,pstgPriority,grfMode,snbExclude,reserved,
ppstgOpen);
*ppstgOpen = (IStorage32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStorage32));
((_IStorage32*)(*ppstgOpen))->ref = 1;
((_IStorage32*)(*ppstgOpen))->lpvtbl = &stvt32;
return S_OK;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
......@@ -158,7 +158,7 @@ type win32
155 stub UtConvertDvtd32toDvtd16
156 stub UtGetDvtd16Info
157 stub UtGetDvtd32Info
158 stub WriteClassStg
158 stdcall WriteClassStg(ptr ptr) WriteClassStg32
159 stub WriteClassStm
160 stub WriteFmtUserTypeStg
161 stub WriteOleStg
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment