ReactOS 0.4.15-dev-8145-ga541a46
storage.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "chm_lib.h"
#include "itsstor.h"
#include "wine/itss.h"
#include "wine/debug.h"
Include dependency graph for storage.c:

Go to the source code of this file.

Classes

struct  _ITSS_IStorageImpl
 
struct  enum_info
 
struct  _IEnumSTATSTG_Impl
 
struct  _IStream_Impl
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct _ITSS_IStorageImpl ITSS_IStorageImpl
 
typedef struct _IEnumSTATSTG_Impl IEnumSTATSTG_Impl
 
typedef struct _IStream_Impl IStream_Impl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (itss)
 
static ITSS_IStorageImplimpl_from_IStorage (IStorage *iface)
 
static IEnumSTATSTG_Implimpl_from_IEnumSTATSTG (IEnumSTATSTG *iface)
 
static IStream_Implimpl_from_IStream (IStream *iface)
 
static HRESULT ITSS_create_chm_storage (struct chmFile *chmfile, const WCHAR *dir, IStorage **ppstgOpen)
 
static IStream_ImplITSS_create_stream (ITSS_IStorageImpl *stg, struct chmUnitInfo *ui)
 
static HRESULT WINAPI ITSS_IEnumSTATSTG_QueryInterface (IEnumSTATSTG *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef (IEnumSTATSTG *iface)
 
static ULONG WINAPI ITSS_IEnumSTATSTG_Release (IEnumSTATSTG *iface)
 
static HRESULT WINAPI ITSS_IEnumSTATSTG_Next (IEnumSTATSTG *iface, ULONG celt, STATSTG *rgelt, ULONG *pceltFetched)
 
static HRESULT WINAPI ITSS_IEnumSTATSTG_Skip (IEnumSTATSTG *iface, ULONG celt)
 
static HRESULT WINAPI ITSS_IEnumSTATSTG_Reset (IEnumSTATSTG *iface)
 
static HRESULT WINAPI ITSS_IEnumSTATSTG_Clone (IEnumSTATSTG *iface, IEnumSTATSTG **ppenum)
 
static IEnumSTATSTG_ImplITSS_create_enum (void)
 
static HRESULT WINAPI ITSS_IStorageImpl_QueryInterface (IStorage *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI ITSS_IStorageImpl_AddRef (IStorage *iface)
 
static ULONG WINAPI ITSS_IStorageImpl_Release (IStorage *iface)
 
static HRESULT WINAPI ITSS_IStorageImpl_CreateStream (IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
 
static HRESULT WINAPI ITSS_IStorageImpl_OpenStream (IStorage *iface, LPCOLESTR pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
 
static HRESULT WINAPI ITSS_IStorageImpl_CreateStorage (IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage **ppstg)
 
static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage (IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
 
static HRESULT WINAPI ITSS_IStorageImpl_CopyTo (IStorage *iface, DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
 
static HRESULT WINAPI ITSS_IStorageImpl_MoveElementTo (IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgDest, LPCOLESTR pwcsNewName, DWORD grfFlags)
 
static HRESULT WINAPI ITSS_IStorageImpl_Commit (IStorage *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI ITSS_IStorageImpl_Revert (IStorage *iface)
 
static int ITSS_chm_enumerator (struct chmFile *h, struct chmUnitInfo *ui, void *context)
 
static HRESULT WINAPI ITSS_IStorageImpl_EnumElements (IStorage *iface, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
 
static HRESULT WINAPI ITSS_IStorageImpl_DestroyElement (IStorage *iface, LPCOLESTR pwcsName)
 
static HRESULT WINAPI ITSS_IStorageImpl_RenameElement (IStorage *iface, LPCOLESTR pwcsOldName, LPCOLESTR pwcsNewName)
 
static HRESULT WINAPI ITSS_IStorageImpl_SetElementTimes (IStorage *iface, LPCOLESTR pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
 
static HRESULT WINAPI ITSS_IStorageImpl_SetClass (IStorage *iface, REFCLSID clsid)
 
static HRESULT WINAPI ITSS_IStorageImpl_SetStateBits (IStorage *iface, DWORD grfStateBits, DWORD grfMask)
 
static HRESULT WINAPI ITSS_IStorageImpl_Stat (IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
HRESULT ITSS_StgOpenStorage (const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
 
static HRESULT WINAPI ITSS_IStream_QueryInterface (IStream *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI ITSS_IStream_AddRef (IStream *iface)
 
static ULONG WINAPI ITSS_IStream_Release (IStream *iface)
 
static HRESULT WINAPI ITSS_IStream_Read (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI ITSS_IStream_Write (IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI ITSS_IStream_Seek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI ITSS_IStream_SetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI ITSS_IStream_CopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI ITSS_IStream_Commit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI ITSS_IStream_Revert (IStream *iface)
 
static HRESULT WINAPI ITSS_IStream_LockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI ITSS_IStream_UnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI ITSS_IStream_Stat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI ITSS_IStream_Clone (IStream *iface, IStream **ppstm)
 

Variables

static const IEnumSTATSTGVtbl IEnumSTATSTG_vtbl
 
static const IStorageVtbl ITSS_IStorageImpl_Vtbl
 
static const IStreamVtbl ITSS_IStream_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 27 of file storage.c.

Typedef Documentation

◆ IEnumSTATSTG_Impl

◆ IStream_Impl

◆ ITSS_IStorageImpl

Function Documentation

◆ impl_from_IEnumSTATSTG()

static IEnumSTATSTG_Impl * impl_from_IEnumSTATSTG ( IEnumSTATSTG iface)
inlinestatic

Definition at line 79 of file storage.c.

80{
81 return CONTAINING_RECORD(iface, IEnumSTATSTG_Impl, IEnumSTATSTG_iface);
82}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by ITSS_IEnumSTATSTG_AddRef(), ITSS_IEnumSTATSTG_Next(), ITSS_IEnumSTATSTG_QueryInterface(), ITSS_IEnumSTATSTG_Release(), ITSS_IEnumSTATSTG_Reset(), and ITSS_IEnumSTATSTG_Skip().

◆ impl_from_IStorage()

◆ impl_from_IStream()

static IStream_Impl * impl_from_IStream ( IStream iface)
inlinestatic

◆ ITSS_chm_enumerator()

static int ITSS_chm_enumerator ( struct chmFile h,
struct chmUnitInfo ui,
void context 
)
static

Definition at line 484 of file storage.c.

488{
489 struct enum_info *info;
490 IEnumSTATSTG_Impl* stgenum = context;
491
492 TRACE("adding %s to enumeration\n", debugstr_w(ui->path) );
493
494 info = HeapAlloc( GetProcessHeap(), 0, sizeof (struct enum_info) );
495 info->ui = *ui;
496
497 info->next = NULL;
498 info->prev = stgenum->last;
499 if( stgenum->last )
500 stgenum->last->next = info;
501 else
502 stgenum->first = info;
503 stgenum->last = info;
504
506}
#define CHM_ENUMERATOR_CONTINUE
Definition: chm_lib.h:106
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define debugstr_w
Definition: kernel32.h:32
UINT ui
Definition: oleauto.h:49
#define TRACE(s)
Definition: solgame.cpp:4
struct enum_info * first
Definition: storage.c:62
struct enum_info * last
Definition: storage.c:62
Definition: http.c:7252

Referenced by ITSS_IStorageImpl_EnumElements().

◆ ITSS_create_chm_storage()

static HRESULT ITSS_create_chm_storage ( struct chmFile chmfile,
const WCHAR dir,
IStorage **  ppstgOpen 
)
static

Definition at line 613 of file storage.c.

615{
617
618 TRACE("%p %s\n", chmfile, debugstr_w( dir ) );
619
620 stg = HeapAlloc( GetProcessHeap(), 0,
623 stg->ref = 1;
624 stg->chmfile = chmfile;
625 lstrcpyW( stg->dir, dir );
626
627 *ppstgOpen = &stg->IStorage_iface;
628
630 return S_OK;
631}
unsigned int dir
Definition: maze.c:112
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
#define S_OK
Definition: intsafe.h:52
static const IStorageVtbl ITSS_IStorageImpl_Vtbl
Definition: storage.c:591
static void ITSS_LockModule(void)
Definition: itsstor.h:41
IStorage IStorage_iface
Definition: storage.c:46
WCHAR dir[1]
Definition: storage.c:49
struct chmFile * chmfile
Definition: storage.c:48
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by ITSS_IStorageImpl_OpenStorage(), and ITSS_StgOpenStorage().

◆ ITSS_create_enum()

static IEnumSTATSTG_Impl * ITSS_create_enum ( void  )
static

Definition at line 254 of file storage.c.

255{
256 IEnumSTATSTG_Impl *stgenum;
257
258 stgenum = HeapAlloc( GetProcessHeap(), 0, sizeof (IEnumSTATSTG_Impl) );
259 stgenum->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTG_vtbl;
260 stgenum->ref = 1;
261 stgenum->first = NULL;
262 stgenum->last = NULL;
263 stgenum->current = NULL;
264
266 TRACE(" -> %p\n", stgenum );
267
268 return stgenum;
269}
static const IEnumSTATSTGVtbl IEnumSTATSTG_vtbl
Definition: storage.c:243
struct enum_info * current
Definition: storage.c:62
IEnumSTATSTG IEnumSTATSTG_iface
Definition: storage.c:60

Referenced by ITSS_IStorageImpl_EnumElements().

◆ ITSS_create_stream()

static IStream_Impl * ITSS_create_stream ( ITSS_IStorageImpl stg,
struct chmUnitInfo ui 
)
static

Definition at line 867 of file storage.c.

869{
870 IStream_Impl *stm;
871
872 stm = HeapAlloc( GetProcessHeap(), 0, sizeof (IStream_Impl) );
873 stm->IStream_iface.lpVtbl = &ITSS_IStream_vtbl;
874 stm->ref = 1;
875 stm->addr = 0;
876 stm->ui = *ui;
877 stm->stg = stg;
878 IStorage_AddRef( &stg->IStorage_iface );
879
881
882 TRACE(" -> %p\n", stm );
883
884 return stm;
885}
static const IStreamVtbl ITSS_IStream_vtbl
Definition: storage.c:849
IStream IStream_iface
Definition: storage.c:67
struct chmUnitInfo ui
Definition: storage.c:71
ITSS_IStorageImpl * stg
Definition: storage.c:69
ULONGLONG addr
Definition: storage.c:70
LONG ref
Definition: storage.c:68

Referenced by ITSS_IStorageImpl_OpenStream().

◆ ITSS_IEnumSTATSTG_AddRef()

static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef ( IEnumSTATSTG iface)
static

Definition at line 115 of file storage.c.

117{
119 return InterlockedIncrement(&This->ref);
120}
#define InterlockedIncrement
Definition: armddk.h:53
static IEnumSTATSTG_Impl * impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
Definition: storage.c:79

◆ ITSS_IEnumSTATSTG_Clone()

static HRESULT WINAPI ITSS_IEnumSTATSTG_Clone ( IEnumSTATSTG iface,
IEnumSTATSTG **  ppenum 
)
static

Definition at line 235 of file storage.c.

238{
239 FIXME("\n");
240 return E_NOTIMPL;
241}
#define FIXME(fmt,...)
Definition: debug.h:114
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ITSS_IEnumSTATSTG_Next()

static HRESULT WINAPI ITSS_IEnumSTATSTG_Next ( IEnumSTATSTG iface,
ULONG  celt,
STATSTG *  rgelt,
ULONG pceltFetched 
)
static

Definition at line 144 of file storage.c.

149{
151 DWORD len, n;
152 struct enum_info *cur;
153
154 TRACE("%p %u %p %p\n", This, celt, rgelt, pceltFetched );
155
156 cur = This->current;
157 n = 0;
158 while( (n<celt) && cur)
159 {
160 WCHAR *str;
161
162 memset( rgelt, 0, sizeof *rgelt );
163
164 /* copy the name */
165 str = cur->ui.path;
166 if( *str == '/' )
167 str++;
168 len = lstrlenW( str ) + 1;
169 rgelt->pwcsName = CoTaskMemAlloc( len*sizeof(WCHAR) );
170 lstrcpyW( rgelt->pwcsName, str );
171
172 /* determine the type */
173 if( rgelt->pwcsName[len-2] == '/' )
174 {
175 rgelt->pwcsName[len-2] = 0;
176 rgelt->type = STGTY_STORAGE;
177 }
178 else
179 rgelt->type = STGTY_STREAM;
180
181 /* copy the size */
182 rgelt->cbSize.QuadPart = cur->ui.length;
183
184 /* advance to the next item if it exists */
185 n++;
186 cur = cur->next;
187 }
188
189 This->current = cur;
190 *pceltFetched = n;
191
192 if( n < celt )
193 return S_FALSE;
194
195 return S_OK;
196}
unsigned long DWORD
Definition: ntddk_ex.h:95
FxCollectionEntry * cur
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
#define S_FALSE
Definition: winerror.h:2357
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ITSS_IEnumSTATSTG_QueryInterface()

static HRESULT WINAPI ITSS_IEnumSTATSTG_QueryInterface ( IEnumSTATSTG iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 96 of file storage.c.

100{
102
105 {
106 IEnumSTATSTG_AddRef(iface);
107 *ppvObject = &This->IEnumSTATSTG_iface;
108 return S_OK;
109 }
110
111 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
112 return E_NOINTERFACE;
113}
const GUID IID_IUnknown
#define WARN(fmt,...)
Definition: debug.h:115
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
const GUID IID_IEnumSTATSTG
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ITSS_IEnumSTATSTG_Release()

static ULONG WINAPI ITSS_IEnumSTATSTG_Release ( IEnumSTATSTG iface)
static

Definition at line 122 of file storage.c.

124{
126
128
129 if (ref == 0)
130 {
131 while( This->first )
132 {
133 struct enum_info *t = This->first->next;
134 HeapFree( GetProcessHeap(), 0, This->first );
135 This->first = t;
136 }
139 }
140
141 return ref;
142}
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:735
GLdouble GLdouble t
Definition: gl.h:2047
static void ITSS_UnlockModule(void)
Definition: itsstor.h:42
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ ITSS_IEnumSTATSTG_Reset()

static HRESULT WINAPI ITSS_IEnumSTATSTG_Reset ( IEnumSTATSTG iface)
static

Definition at line 223 of file storage.c.

225{
227
228 TRACE("%p\n", This );
229
230 This->current = This->first;
231
232 return S_OK;
233}

◆ ITSS_IEnumSTATSTG_Skip()

static HRESULT WINAPI ITSS_IEnumSTATSTG_Skip ( IEnumSTATSTG iface,
ULONG  celt 
)
static

Definition at line 198 of file storage.c.

201{
203 DWORD n;
204 struct enum_info *cur;
205
206 TRACE("%p %u\n", This, celt );
207
208 cur = This->current;
209 n = 0;
210 while( (n<celt) && cur)
211 {
212 n++;
213 cur = cur->next;
214 }
215 This->current = cur;
216
217 if( n < celt )
218 return S_FALSE;
219
220 return S_OK;
221}

◆ ITSS_IStorageImpl_AddRef()

static ULONG WINAPI ITSS_IStorageImpl_AddRef ( IStorage iface)
static

Definition at line 292 of file storage.c.

294{
296 return InterlockedIncrement(&This->ref);
297}
static ITSS_IStorageImpl * impl_from_IStorage(IStorage *iface)
Definition: storage.c:74

◆ ITSS_IStorageImpl_Commit()

static HRESULT WINAPI ITSS_IStorageImpl_Commit ( IStorage iface,
DWORD  grfCommitFlags 
)
static

Definition at line 469 of file storage.c.

472{
473 FIXME("\n");
474 return E_NOTIMPL;
475}

◆ ITSS_IStorageImpl_CopyTo()

static HRESULT WINAPI ITSS_IStorageImpl_CopyTo ( IStorage iface,
DWORD  ciidExclude,
const IID rgiidExclude,
SNB  snbExclude,
IStorage pstgDest 
)
static

Definition at line 447 of file storage.c.

453{
454 FIXME("\n");
455 return E_NOTIMPL;
456}

◆ ITSS_IStorageImpl_CreateStorage()

static HRESULT WINAPI ITSS_IStorageImpl_CreateStorage ( IStorage iface,
LPCOLESTR  pwcsName,
DWORD  grfMode,
DWORD  dwStgFmt,
DWORD  reserved2,
IStorage **  ppstg 
)
static

Definition at line 385 of file storage.c.

392{
393 FIXME("\n");
394 return E_NOTIMPL;
395}

◆ ITSS_IStorageImpl_CreateStream()

static HRESULT WINAPI ITSS_IStorageImpl_CreateStream ( IStorage iface,
LPCOLESTR  pwcsName,
DWORD  grfMode,
DWORD  reserved1,
DWORD  reserved2,
IStream **  ppstm 
)
static

Definition at line 316 of file storage.c.

323{
324 FIXME("\n");
325 return E_NOTIMPL;
326}

◆ ITSS_IStorageImpl_DestroyElement()

static HRESULT WINAPI ITSS_IStorageImpl_DestroyElement ( IStorage iface,
LPCOLESTR  pwcsName 
)
static

Definition at line 537 of file storage.c.

540{
541 FIXME("\n");
542 return E_NOTIMPL;
543}

◆ ITSS_IStorageImpl_EnumElements()

static HRESULT WINAPI ITSS_IStorageImpl_EnumElements ( IStorage iface,
DWORD  reserved1,
void reserved2,
DWORD  reserved3,
IEnumSTATSTG **  ppenum 
)
static

Definition at line 508 of file storage.c.

514{
516 IEnumSTATSTG_Impl* stgenum;
517
518 TRACE("%p %d %p %d %p\n", This, reserved1, reserved2, reserved3, ppenum );
519
520 stgenum = ITSS_create_enum();
521 if( !stgenum )
522 return E_FAIL;
523
524 chm_enumerate_dir(This->chmfile,
525 This->dir,
528 stgenum );
529
530 stgenum->current = stgenum->first;
531
532 *ppenum = &stgenum->IEnumSTATSTG_iface;
533
534 return S_OK;
535}
BOOL chm_enumerate_dir(struct chmFile *h, const WCHAR *prefix, int what, CHM_ENUMERATOR e, void *context)
Definition: chm_lib.c:1400
#define CHM_ENUMERATE_ALL
Definition: chm_lib.h:104
#define E_FAIL
Definition: ddrawi.h:102
uint8_t reserved2[12]
Definition: fsck.fat.h:23
uint8_t reserved3
Definition: fsck.fat.h:26
static IEnumSTATSTG_Impl * ITSS_create_enum(void)
Definition: storage.c:254
static int ITSS_chm_enumerator(struct chmFile *h, struct chmUnitInfo *ui, void *context)
Definition: storage.c:484

◆ ITSS_IStorageImpl_MoveElementTo()

static HRESULT WINAPI ITSS_IStorageImpl_MoveElementTo ( IStorage iface,
LPCOLESTR  pwcsName,
IStorage pstgDest,
LPCOLESTR  pwcsNewName,
DWORD  grfFlags 
)
static

Definition at line 458 of file storage.c.

464{
465 FIXME("\n");
466 return E_NOTIMPL;
467}

◆ ITSS_IStorageImpl_OpenStorage()

static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage ( IStorage iface,
LPCOLESTR  pwcsName,
IStorage pstgPriority,
DWORD  grfMode,
SNB  snbExclude,
DWORD  reserved,
IStorage **  ppstg 
)
static

Definition at line 397 of file storage.c.

405{
407 struct chmFile *chmfile;
408 WCHAR *path, *p;
409 DWORD len;
410
411 TRACE("%p %s %p %u %p %u %p\n", This, debugstr_w(pwcsName),
412 pstgPriority, grfMode, snbExclude, reserved, ppstg);
413
414 chmfile = chm_dup( This->chmfile );
415 if( !chmfile )
416 return E_FAIL;
417
418 len = lstrlenW( This->dir ) + lstrlenW( pwcsName ) + 2; /* need room for a terminating slash */
419 path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
420 lstrcpyW( path, This->dir );
421
422 if( pwcsName[0] == '/' || pwcsName[0] == '\\' )
423 {
424 p = &path[lstrlenW( path ) - 1];
425 while( ( path <= p ) && ( *p == '/' ) )
426 *p-- = 0;
427 }
428 lstrcatW( path, pwcsName );
429
430 for(p=path; *p; p++) {
431 if(*p == '\\')
432 *p = '/';
433 }
434
435 /* add a terminating slash if one does not already exist */
436 if(*(p-1) != '/')
437 {
438 *p++ = '/';
439 *p = 0;
440 }
441
442 TRACE("Resolving %s\n", debugstr_w(path));
443
444 return ITSS_create_chm_storage(chmfile, path, ppstg);
445}
struct chmFile * chm_dup(struct chmFile *oldHandle)
Definition: chm_lib.c:831
r reserved
Definition: btrfs.c:3006
GLfloat GLfloat p
Definition: glext.h:8902
static HRESULT ITSS_create_chm_storage(struct chmFile *chmfile, const WCHAR *dir, IStorage **ppstgOpen)
Definition: storage.c:613
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

◆ ITSS_IStorageImpl_OpenStream()

static HRESULT WINAPI ITSS_IStorageImpl_OpenStream ( IStorage iface,
LPCOLESTR  pwcsName,
void reserved1,
DWORD  grfMode,
DWORD  reserved2,
IStream **  ppstm 
)
static

Definition at line 328 of file storage.c.

335{
337 IStream_Impl *stm;
338 DWORD len;
339 struct chmUnitInfo ui;
340 int r;
341 WCHAR *path, *p;
342
343 TRACE("%p %s %p %u %u %p\n", This, debugstr_w(pwcsName),
344 reserved1, grfMode, reserved2, ppstm );
345
346 len = lstrlenW( This->dir ) + lstrlenW( pwcsName ) + 1;
347 path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
348 lstrcpyW( path, This->dir );
349
350 if( pwcsName[0] == '/' || pwcsName[0] == '\\' )
351 {
352 p = &path[lstrlenW( path ) - 1];
353 while( ( path <= p ) && ( *p == '/' ) )
354 *p-- = 0;
355 }
356 lstrcatW( path, pwcsName );
357
358 for(p=path; *p; p++) {
359 if(*p == '\\')
360 *p = '/';
361 }
362
363 if(*--p == '/')
364 *p = 0;
365
366 TRACE("Resolving %s\n", debugstr_w(path));
367
368 r = chm_resolve_object(This->chmfile, path, &ui);
370
371 if( r != CHM_RESOLVE_SUCCESS ) {
372 WARN("Could not resolve object\n");
373 return STG_E_FILENOTFOUND;
374 }
375
376 stm = ITSS_create_stream( This, &ui );
377 if( !stm )
378 return E_FAIL;
379
380 *ppstm = &stm->IStream_iface;
381
382 return S_OK;
383}
int chm_resolve_object(struct chmFile *h, const WCHAR *objPath, struct chmUnitInfo *ui)
Definition: chm_lib.c:1048
#define CHM_RESOLVE_SUCCESS
Definition: chm_lib.h:82
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static IStream_Impl * ITSS_create_stream(ITSS_IStorageImpl *stg, struct chmUnitInfo *ui)
Definition: storage.c:867
WCHAR path[CHM_MAX_PATHLEN+1]
Definition: chm_lib.h:72
#define STG_E_FILENOTFOUND
Definition: winerror.h:2565

◆ ITSS_IStorageImpl_QueryInterface()

static HRESULT WINAPI ITSS_IStorageImpl_QueryInterface ( IStorage iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 273 of file storage.c.

277{
279
281 || IsEqualGUID(riid, &IID_IStorage))
282 {
283 IStorage_AddRef(iface);
284 *ppvObject = &This->IStorage_iface;
285 return S_OK;
286 }
287
288 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
289 return E_NOINTERFACE;
290}

◆ ITSS_IStorageImpl_Release()

static ULONG WINAPI ITSS_IStorageImpl_Release ( IStorage iface)
static

Definition at line 299 of file storage.c.

301{
303
305
306 if (ref == 0)
307 {
308 chm_close(This->chmfile);
311 }
312
313 return ref;
314}
void chm_close(struct chmFile *h)
Definition: chm_lib.c:863

◆ ITSS_IStorageImpl_RenameElement()

static HRESULT WINAPI ITSS_IStorageImpl_RenameElement ( IStorage iface,
LPCOLESTR  pwcsOldName,
LPCOLESTR  pwcsNewName 
)
static

Definition at line 545 of file storage.c.

549{
550 FIXME("\n");
551 return E_NOTIMPL;
552}

◆ ITSS_IStorageImpl_Revert()

static HRESULT WINAPI ITSS_IStorageImpl_Revert ( IStorage iface)
static

Definition at line 477 of file storage.c.

479{
480 FIXME("\n");
481 return E_NOTIMPL;
482}

◆ ITSS_IStorageImpl_SetClass()

static HRESULT WINAPI ITSS_IStorageImpl_SetClass ( IStorage iface,
REFCLSID  clsid 
)
static

Definition at line 565 of file storage.c.

568{
569 FIXME("\n");
570 return E_NOTIMPL;
571}

◆ ITSS_IStorageImpl_SetElementTimes()

static HRESULT WINAPI ITSS_IStorageImpl_SetElementTimes ( IStorage iface,
LPCOLESTR  pwcsName,
const FILETIME pctime,
const FILETIME patime,
const FILETIME pmtime 
)
static

Definition at line 554 of file storage.c.

560{
561 FIXME("\n");
562 return E_NOTIMPL;
563}

◆ ITSS_IStorageImpl_SetStateBits()

static HRESULT WINAPI ITSS_IStorageImpl_SetStateBits ( IStorage iface,
DWORD  grfStateBits,
DWORD  grfMask 
)
static

Definition at line 573 of file storage.c.

577{
578 FIXME("\n");
579 return E_NOTIMPL;
580}

◆ ITSS_IStorageImpl_Stat()

static HRESULT WINAPI ITSS_IStorageImpl_Stat ( IStorage iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 582 of file storage.c.

586{
587 FIXME("\n");
588 return E_NOTIMPL;
589}

◆ ITSS_IStream_AddRef()

static ULONG WINAPI ITSS_IStream_AddRef ( IStream iface)
static

Definition at line 675 of file storage.c.

677{
679 return InterlockedIncrement(&This->ref);
680}
static IStream_Impl * impl_from_IStream(IStream *iface)
Definition: storage.c:84

◆ ITSS_IStream_Clone()

static HRESULT WINAPI ITSS_IStream_Clone ( IStream iface,
IStream **  ppstm 
)
static

Definition at line 841 of file storage.c.

844{
845 FIXME("\n");
846 return E_NOTIMPL;
847}

◆ ITSS_IStream_Commit()

static HRESULT WINAPI ITSS_IStream_Commit ( IStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 784 of file storage.c.

787{
788 FIXME("\n");
789 return E_NOTIMPL;
790}

◆ ITSS_IStream_CopyTo()

static HRESULT WINAPI ITSS_IStream_CopyTo ( IStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 773 of file storage.c.

779{
780 FIXME("\n");
781 return E_NOTIMPL;
782}

◆ ITSS_IStream_LockRegion()

static HRESULT WINAPI ITSS_IStream_LockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 799 of file storage.c.

804{
805 FIXME("\n");
806 return E_NOTIMPL;
807}

◆ ITSS_IStream_QueryInterface()

static HRESULT WINAPI ITSS_IStream_QueryInterface ( IStream iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 655 of file storage.c.

659{
661
663 || IsEqualGUID(riid, &IID_ISequentialStream)
664 || IsEqualGUID(riid, &IID_IStream))
665 {
666 IStream_AddRef(iface);
667 *ppvObject = &This->IStream_iface;
668 return S_OK;
669 }
670
671 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
672 return E_NOINTERFACE;
673}

◆ ITSS_IStream_Read()

static HRESULT WINAPI ITSS_IStream_Read ( IStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 699 of file storage.c.

704{
706 ULONG count;
707
708 TRACE("%p %p %u %p\n", This, pv, cb, pcbRead);
709
710 count = chm_retrieve_object(This->stg->chmfile,
711 &This->ui, pv, This->addr, cb);
712 This->addr += count;
713 if( pcbRead )
714 *pcbRead = count;
715
716 return count ? S_OK : S_FALSE;
717}
LONGINT64 chm_retrieve_object(struct chmFile *h, struct chmUnitInfo *ui, unsigned char *buf, LONGUINT64 addr, LONGINT64 len)
Definition: chm_lib.c:1342
GLuint GLuint GLsizei count
Definition: gl.h:1545
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33

◆ ITSS_IStream_Release()

static ULONG WINAPI ITSS_IStream_Release ( IStream iface)
static

Definition at line 682 of file storage.c.

684{
686
688
689 if (ref == 0)
690 {
691 IStorage_Release( &This->stg->IStorage_iface );
694 }
695
696 return ref;
697}

◆ ITSS_IStream_Revert()

static HRESULT WINAPI ITSS_IStream_Revert ( IStream iface)
static

Definition at line 792 of file storage.c.

794{
795 FIXME("\n");
796 return E_NOTIMPL;
797}

◆ ITSS_IStream_Seek()

static HRESULT WINAPI ITSS_IStream_Seek ( IStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 729 of file storage.c.

734{
736 LONGLONG newpos;
737
738 TRACE("%p %s %u %p\n", This,
739 wine_dbgstr_longlong( dlibMove.QuadPart ), dwOrigin, plibNewPosition );
740
741 newpos = This->addr;
742 switch( dwOrigin )
743 {
744 case STREAM_SEEK_CUR:
745 newpos = This->addr + dlibMove.QuadPart;
746 break;
747 case STREAM_SEEK_SET:
748 newpos = dlibMove.QuadPart;
749 break;
750 case STREAM_SEEK_END:
751 newpos = This->ui.length + dlibMove.QuadPart;
752 break;
753 }
754
755 if( ( newpos < 0 ) || ( newpos > This->ui.length ) )
757
758 This->addr = newpos;
759 if( plibNewPosition )
760 plibNewPosition->QuadPart = This->addr;
761
762 return S_OK;
763}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571

◆ ITSS_IStream_SetSize()

static HRESULT WINAPI ITSS_IStream_SetSize ( IStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 765 of file storage.c.

768{
769 FIXME("\n");
770 return E_NOTIMPL;
771}

◆ ITSS_IStream_Stat()

static HRESULT WINAPI ITSS_IStream_Stat ( IStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 819 of file storage.c.

823{
825
826 TRACE("%p %p %d\n", This, pstatstg, grfStatFlag);
827
828 memset( pstatstg, 0, sizeof *pstatstg );
829 if( !( grfStatFlag & STATFLAG_NONAME ) )
830 {
831 FIXME("copy the name\n");
832 }
833 pstatstg->type = STGTY_STREAM;
834 pstatstg->cbSize.QuadPart = This->ui.length;
835 pstatstg->grfMode = STGM_READ;
836 pstatstg->clsid = CLSID_ITStorage;
837
838 return S_OK;
839}
#define STGM_READ
Definition: objbase.h:917

◆ ITSS_IStream_UnlockRegion()

static HRESULT WINAPI ITSS_IStream_UnlockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 809 of file storage.c.

814{
815 FIXME("\n");
816 return E_NOTIMPL;
817}

◆ ITSS_IStream_Write()

static HRESULT WINAPI ITSS_IStream_Write ( IStream iface,
const void pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 719 of file storage.c.

724{
725 FIXME("\n");
726 return E_NOTIMPL;
727}

◆ ITSS_StgOpenStorage()

HRESULT ITSS_StgOpenStorage ( const WCHAR pwcsName,
IStorage pstgPriority,
DWORD  grfMode,
SNB  snbExclude,
DWORD  reserved,
IStorage **  ppstgOpen 
)

Definition at line 633 of file storage.c.

640{
641 struct chmFile *chmfile;
642 static const WCHAR szRoot[] = { '/', 0 };
643
644 TRACE("%s\n", debugstr_w(pwcsName) );
645
646 chmfile = chm_openW( pwcsName );
647 if( !chmfile )
648 return E_FAIL;
649
650 return ITSS_create_chm_storage( chmfile, szRoot, ppstgOpen );
651}
struct chmFile * chm_openW(const WCHAR *filename)
Definition: chm_lib.c:678

Referenced by ITS_IMonikerImpl_BindToStorage(), ITStorageImpl_StgCreateDocfile(), and ITStorageImpl_StgOpenStorage().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( itss  )

Variable Documentation

◆ IEnumSTATSTG_vtbl

const IEnumSTATSTGVtbl IEnumSTATSTG_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ITSS_IEnumSTATSTG_Reset(IEnumSTATSTG *iface)
Definition: storage.c:223
static HRESULT WINAPI ITSS_IEnumSTATSTG_QueryInterface(IEnumSTATSTG *iface, REFIID riid, void **ppvObject)
Definition: storage.c:96
static HRESULT WINAPI ITSS_IEnumSTATSTG_Clone(IEnumSTATSTG *iface, IEnumSTATSTG **ppenum)
Definition: storage.c:235
static HRESULT WINAPI ITSS_IEnumSTATSTG_Next(IEnumSTATSTG *iface, ULONG celt, STATSTG *rgelt, ULONG *pceltFetched)
Definition: storage.c:144
static ULONG WINAPI ITSS_IEnumSTATSTG_Release(IEnumSTATSTG *iface)
Definition: storage.c:122
static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef(IEnumSTATSTG *iface)
Definition: storage.c:115
static HRESULT WINAPI ITSS_IEnumSTATSTG_Skip(IEnumSTATSTG *iface, ULONG celt)
Definition: storage.c:198

Definition at line 243 of file storage.c.

Referenced by ITSS_create_enum().

◆ ITSS_IStorageImpl_Vtbl

const IStorageVtbl ITSS_IStorageImpl_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ITSS_IStorageImpl_CreateStorage(IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage **ppstg)
Definition: storage.c:385
static HRESULT WINAPI ITSS_IStorageImpl_CopyTo(IStorage *iface, DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
Definition: storage.c:447
static HRESULT WINAPI ITSS_IStorageImpl_RenameElement(IStorage *iface, LPCOLESTR pwcsOldName, LPCOLESTR pwcsNewName)
Definition: storage.c:545
static HRESULT WINAPI ITSS_IStorageImpl_Commit(IStorage *iface, DWORD grfCommitFlags)
Definition: storage.c:469
static HRESULT WINAPI ITSS_IStorageImpl_SetClass(IStorage *iface, REFCLSID clsid)
Definition: storage.c:565
static HRESULT WINAPI ITSS_IStorageImpl_Revert(IStorage *iface)
Definition: storage.c:477
static HRESULT WINAPI ITSS_IStorageImpl_EnumElements(IStorage *iface, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
Definition: storage.c:508
static HRESULT WINAPI ITSS_IStorageImpl_QueryInterface(IStorage *iface, REFIID riid, void **ppvObject)
Definition: storage.c:273
static HRESULT WINAPI ITSS_IStorageImpl_SetElementTimes(IStorage *iface, LPCOLESTR pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
Definition: storage.c:554
static HRESULT WINAPI ITSS_IStorageImpl_CreateStream(IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
Definition: storage.c:316
static HRESULT WINAPI ITSS_IStorageImpl_MoveElementTo(IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgDest, LPCOLESTR pwcsNewName, DWORD grfFlags)
Definition: storage.c:458
static HRESULT WINAPI ITSS_IStorageImpl_SetStateBits(IStorage *iface, DWORD grfStateBits, DWORD grfMask)
Definition: storage.c:573
static HRESULT WINAPI ITSS_IStorageImpl_OpenStream(IStorage *iface, LPCOLESTR pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
Definition: storage.c:328
static ULONG WINAPI ITSS_IStorageImpl_AddRef(IStorage *iface)
Definition: storage.c:292
static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage(IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
Definition: storage.c:397
static HRESULT WINAPI ITSS_IStorageImpl_Stat(IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: storage.c:582
static HRESULT WINAPI ITSS_IStorageImpl_DestroyElement(IStorage *iface, LPCOLESTR pwcsName)
Definition: storage.c:537
static ULONG WINAPI ITSS_IStorageImpl_Release(IStorage *iface)
Definition: storage.c:299

Definition at line 591 of file storage.c.

Referenced by ITSS_create_chm_storage().

◆ ITSS_IStream_vtbl

const IStreamVtbl ITSS_IStream_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ITSS_IStream_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: storage.c:729
static HRESULT WINAPI ITSS_IStream_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: storage.c:784
static HRESULT WINAPI ITSS_IStream_Clone(IStream *iface, IStream **ppstm)
Definition: storage.c:841
static HRESULT WINAPI ITSS_IStream_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: storage.c:819
static HRESULT WINAPI ITSS_IStream_QueryInterface(IStream *iface, REFIID riid, void **ppvObject)
Definition: storage.c:655
static ULONG WINAPI ITSS_IStream_Release(IStream *iface)
Definition: storage.c:682
static HRESULT WINAPI ITSS_IStream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: storage.c:765
static HRESULT WINAPI ITSS_IStream_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: storage.c:809
static HRESULT WINAPI ITSS_IStream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: storage.c:799
static HRESULT WINAPI ITSS_IStream_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: storage.c:719
static HRESULT WINAPI ITSS_IStream_Revert(IStream *iface)
Definition: storage.c:792
static ULONG WINAPI ITSS_IStream_AddRef(IStream *iface)
Definition: storage.c:675
static HRESULT WINAPI ITSS_IStream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: storage.c:699
static HRESULT WINAPI ITSS_IStream_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: storage.c:773

Definition at line 849 of file storage.c.

Referenced by ITSS_create_stream().