Implements OleLoadPicturePath.
[wine] / dlls / ole32 / storage32.h
1 /*
2  * Compound Storage (32 bit version)
3  *
4  * Implemented using the documentation of the LAOLA project at
5  * <URL:http://wwwwbs.cs.tu-berlin.de/~schwartz/pmh/index.html>
6  * (Thanks to Martin Schwartz <schwartz@cs.tu-berlin.de>)
7  *
8  * This include file contains definitions of types and function
9  * prototypes that are used in the many files implementing the
10  * storage functionality
11  *
12  * Copyright 1998,1999 Francis Beaudet
13  * Copyright 1998,1999 Thuy Nguyen
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Lesser General Public
17  * License as published by the Free Software Foundation; either
18  * version 2.1 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * Lesser General Public License for more details.
24  *
25  * You should have received a copy of the GNU Lesser General Public
26  * License along with this library; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28  */
29 #ifndef __STORAGE32_H__
30 #define __STORAGE32_H__
31
32 #include <stdarg.h>
33
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winnt.h"
37 #include "objbase.h"
38
39 /*
40  * Definitions for the file format offsets.
41  */
42 static const ULONG OFFSET_BIGBLOCKSIZEBITS   = 0x0000001e;
43 static const ULONG OFFSET_SMALLBLOCKSIZEBITS = 0x00000020;
44 static const ULONG OFFSET_BBDEPOTCOUNT       = 0x0000002C;
45 static const ULONG OFFSET_ROOTSTARTBLOCK     = 0x00000030;
46 static const ULONG OFFSET_SBDEPOTSTART       = 0x0000003C;
47 static const ULONG OFFSET_SBDEPOTCOUNT       = 0x00000040;
48 static const ULONG OFFSET_EXTBBDEPOTSTART    = 0x00000044;
49 static const ULONG OFFSET_EXTBBDEPOTCOUNT    = 0x00000048;
50 static const ULONG OFFSET_BBDEPOTSTART       = 0x0000004C;
51 static const ULONG OFFSET_PS_NAME            = 0x00000000;
52 static const ULONG OFFSET_PS_NAMELENGTH      = 0x00000040;
53 static const ULONG OFFSET_PS_PROPERTYTYPE    = 0x00000042;
54 static const ULONG OFFSET_PS_PREVIOUSPROP    = 0x00000044;
55 static const ULONG OFFSET_PS_NEXTPROP        = 0x00000048;
56 static const ULONG OFFSET_PS_DIRPROP         = 0x0000004C;
57 static const ULONG OFFSET_PS_GUID            = 0x00000050;
58 static const ULONG OFFSET_PS_TSS1            = 0x00000064;
59 static const ULONG OFFSET_PS_TSD1            = 0x00000068;
60 static const ULONG OFFSET_PS_TSS2            = 0x0000006C;
61 static const ULONG OFFSET_PS_TSD2            = 0x00000070;
62 static const ULONG OFFSET_PS_STARTBLOCK      = 0x00000074;
63 static const ULONG OFFSET_PS_SIZE            = 0x00000078;
64 static const WORD  DEF_BIG_BLOCK_SIZE_BITS   = 0x0009;
65 static const WORD  DEF_SMALL_BLOCK_SIZE_BITS = 0x0006;
66 static const WORD  DEF_BIG_BLOCK_SIZE        = 0x0200;
67 static const WORD  DEF_SMALL_BLOCK_SIZE      = 0x0040;
68 static const ULONG BLOCK_EXTBBDEPOT          = 0xFFFFFFFC;
69 static const ULONG BLOCK_SPECIAL             = 0xFFFFFFFD;
70 static const ULONG BLOCK_END_OF_CHAIN        = 0xFFFFFFFE;
71 static const ULONG BLOCK_UNUSED              = 0xFFFFFFFF;
72 static const ULONG PROPERTY_NULL             = 0xFFFFFFFF;
73
74 #define PROPERTY_NAME_MAX_LEN    0x20
75 #define PROPERTY_NAME_BUFFER_LEN 0x40
76
77 #define PROPSET_BLOCK_SIZE 0x00000080
78
79 /*
80  * Property type of relation
81  */
82 #define PROPERTY_RELATION_PREVIOUS 0
83 #define PROPERTY_RELATION_NEXT     1
84 #define PROPERTY_RELATION_DIR      2
85
86 /*
87  * Property type constants
88  */
89 #define PROPTYPE_STORAGE 0x01
90 #define PROPTYPE_STREAM  0x02
91 #define PROPTYPE_ROOT    0x05
92
93 /*
94  * These defines assume a hardcoded blocksize. The code will assert
95  * if the blocksize is different. Some changes will have to be done if it
96  * becomes the case.
97  */
98 #define BIG_BLOCK_SIZE           0x200
99 #define COUNT_BBDEPOTINHEADER    109
100 #define LIMIT_TO_USE_SMALL_BLOCK 0x1000
101 #define NUM_BLOCKS_PER_DEPOT_BLOCK 128
102
103 /*
104  * These are signatures to detect the type of Document file.
105  */
106 static const BYTE STORAGE_magic[8]    ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1};
107 static const BYTE STORAGE_oldmagic[8] ={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d};
108
109 /*
110  * Forward declarations of all the structures used by the storage
111  * module.
112  */
113 typedef struct StorageBaseImpl     StorageBaseImpl;
114 typedef struct StorageImpl         StorageImpl;
115 typedef struct StorageInternalImpl StorageInternalImpl;
116 typedef struct BlockChainStream      BlockChainStream;
117 typedef struct SmallBlockChainStream SmallBlockChainStream;
118 typedef struct IEnumSTATSTGImpl      IEnumSTATSTGImpl;
119 typedef struct StgProperty           StgProperty;
120 typedef struct StgStreamImpl         StgStreamImpl;
121
122 /*
123  * This utility structure is used to read/write the information in a storage
124  * property.
125  */
126 struct StgProperty
127 {
128   WCHAR          name[PROPERTY_NAME_MAX_LEN];
129   WORD           sizeOfNameString;
130   BYTE           propertyType;
131   ULONG          previousProperty;
132   ULONG          nextProperty;
133   ULONG          dirProperty;
134   GUID           propertyUniqueID;
135   ULONG          timeStampS1;
136   ULONG          timeStampD1;
137   ULONG          timeStampS2;
138   ULONG          timeStampD2;
139   ULONG          startingBlock;
140   ULARGE_INTEGER size;
141 };
142
143 /*************************************************************************
144  * Big Block File support
145  *
146  * The big block file is an abstraction of a flat file separated in
147  * same sized blocks. The implementation for the methods described in
148  * this section appear in stg_bigblockfile.c
149  */
150
151 /*
152  * Declaration of the data structures
153  */
154 typedef struct BigBlockFile BigBlockFile,*LPBIGBLOCKFILE;
155 typedef struct MappedPage   MappedPage,*LPMAPPEDPAGE;
156
157 struct BigBlockFile
158 {
159   BOOL fileBased;
160   ULARGE_INTEGER filesize;
161   ULONG blocksize;
162   HANDLE hfile;
163   HANDLE hfilemap;
164   DWORD flProtect;
165   MappedPage *maplist;
166   MappedPage *victimhead, *victimtail;
167   ULONG num_victim_pages;
168   ILockBytes *pLkbyt;
169   HGLOBAL hbytearray;
170   LPVOID pbytearray;
171 };
172
173 /*
174  * Declaration of the functions used to manipulate the BigBlockFile
175  * data structure.
176  */
177 BigBlockFile*  BIGBLOCKFILE_Construct(HANDLE hFile,
178                                       ILockBytes* pLkByt,
179                                       DWORD openFlags,
180                                       ULONG blocksize,
181                                       BOOL fileBased);
182 void           BIGBLOCKFILE_Destructor(LPBIGBLOCKFILE This);
183 void*          BIGBLOCKFILE_GetBigBlock(LPBIGBLOCKFILE This, ULONG index);
184 void*          BIGBLOCKFILE_GetROBigBlock(LPBIGBLOCKFILE This, ULONG index);
185 void           BIGBLOCKFILE_ReleaseBigBlock(LPBIGBLOCKFILE This, void *pBlock);
186 void           BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
187 ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This);
188
189 /*************************************************************************
190  * Ole Convert support
191  */
192
193 void OLECONVERT_CreateOleStream(LPSTORAGE pStorage);
194 HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName);
195
196 /****************************************************************************
197  * Storage32BaseImpl definitions.
198  *
199  * This structure defines the base information contained in all implementations
200  * of IStorage32 contained in this file storage implementation.
201  *
202  * In OOP terms, this is the base class for all the IStorage32 implementations
203  * contained in this file.
204  */
205 struct StorageBaseImpl
206 {
207   IStorageVtbl *lpVtbl;    /* Needs to be the first item in the struct
208                             * since we want to cast this in a Storage32 pointer */
209
210   IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
211
212   /*
213    * Reference count of this object
214    */
215   ULONG ref;
216
217   /*
218    * Ancestor storage (top level)
219    */
220   StorageImpl* ancestorStorage;
221
222   /*
223    * Index of the property for the root of
224    * this storage
225    */
226   ULONG rootPropertySetIndex;
227
228   /*
229    * virtual Destructor method.
230    */
231   void (*v_destructor)(StorageBaseImpl*);
232 };
233
234
235 /*
236  * Prototypes for the methods of the Storage32BaseImpl class.
237  */
238 HRESULT WINAPI StorageBaseImpl_QueryInterface(
239             IStorage*        iface,
240             REFIID             riid,
241             void**             ppvObject);
242
243 ULONG WINAPI StorageBaseImpl_AddRef(
244             IStorage*        iface);
245
246 ULONG WINAPI StorageBaseImpl_Release(
247             IStorage*        iface);
248
249 HRESULT WINAPI StorageBaseImpl_OpenStream(
250             IStorage*        iface,
251             const OLECHAR*   pwcsName,  /* [string][in] */
252             void*              reserved1, /* [unique][in] */
253             DWORD              grfMode,   /* [in] */
254             DWORD              reserved2, /* [in] */
255             IStream**        ppstm);    /* [out] */
256
257 HRESULT WINAPI StorageBaseImpl_OpenStorage(
258             IStorage*        iface,
259             const OLECHAR*   pwcsName,      /* [string][unique][in] */
260             IStorage*        pstgPriority,  /* [unique][in] */
261             DWORD              grfMode,       /* [in] */
262             SNB              snbExclude,    /* [unique][in] */
263             DWORD              reserved,      /* [in] */
264             IStorage**       ppstg);        /* [out] */
265
266 HRESULT WINAPI StorageBaseImpl_EnumElements(
267             IStorage*        iface,
268             DWORD              reserved1, /* [in] */
269             void*              reserved2, /* [size_is][unique][in] */
270             DWORD              reserved3, /* [in] */
271             IEnumSTATSTG**     ppenum);   /* [out] */
272
273 HRESULT WINAPI StorageBaseImpl_Stat(
274             IStorage*        iface,
275             STATSTG*           pstatstg,     /* [out] */
276             DWORD              grfStatFlag); /* [in] */
277
278 HRESULT WINAPI StorageBaseImpl_RenameElement(
279             IStorage*        iface,
280             const OLECHAR*   pwcsOldName,  /* [string][in] */
281             const OLECHAR*   pwcsNewName); /* [string][in] */
282
283 HRESULT WINAPI StorageBaseImpl_CreateStream(
284             IStorage*        iface,
285             const OLECHAR*   pwcsName,  /* [string][in] */
286             DWORD              grfMode,   /* [in] */
287             DWORD              reserved1, /* [in] */
288             DWORD              reserved2, /* [in] */
289             IStream**        ppstm);    /* [out] */
290
291 HRESULT WINAPI StorageBaseImpl_SetClass(
292             IStorage*        iface,
293             REFCLSID           clsid);  /* [in] */
294
295 /****************************************************************************
296  * Storage32Impl definitions.
297  *
298  * This implementation of the IStorage32 interface represents a root
299  * storage. Basically, a document file.
300  */
301 struct StorageImpl
302 {
303   struct StorageBaseImpl base;
304
305   /*
306    * The following data members are specific to the Storage32Impl
307    * class
308    */
309   HANDLE           hFile;      /* Physical support for the Docfile */
310   LPOLESTR         pwcsName;   /* Full path of the document file */
311
312   /* FIXME: should this be in Storage32BaseImpl ? */
313   WCHAR            filename[PROPERTY_NAME_BUFFER_LEN];
314
315   /*
316    * File header
317    */
318   WORD  bigBlockSizeBits;
319   WORD  smallBlockSizeBits;
320   ULONG bigBlockSize;
321   ULONG smallBlockSize;
322   ULONG bigBlockDepotCount;
323   ULONG rootStartBlock;
324   ULONG smallBlockDepotStart;
325   ULONG extBigBlockDepotStart;
326   ULONG extBigBlockDepotCount;
327   ULONG bigBlockDepotStart[COUNT_BBDEPOTINHEADER];
328
329   ULONG blockDepotCached[NUM_BLOCKS_PER_DEPOT_BLOCK];
330   ULONG indexBlockDepotCached;
331   ULONG prevFreeBlock;
332
333   /*
334    * Abstraction of the big block chains for the chains of the header.
335    */
336   BlockChainStream* rootBlockChain;
337   BlockChainStream* smallBlockDepotChain;
338   BlockChainStream* smallBlockRootChain;
339
340   /*
341    * Pointer to the big block file abstraction
342    */
343   BigBlockFile* bigBlockFile;
344 };
345
346 /*
347  * Method declaration for the Storage32Impl class
348  */
349
350 HRESULT WINAPI StorageImpl_CreateStorage(
351             IStorage*      iface,
352             const OLECHAR* pwcsName,  /* [string][in] */
353             DWORD            grfMode,   /* [in] */
354             DWORD            dwStgFmt,  /* [in] */
355             DWORD            reserved2, /* [in] */
356             IStorage**     ppstg);    /* [out] */
357
358 HRESULT WINAPI StorageImpl_CopyTo(
359             IStorage*      iface,
360             DWORD          ciidExclude,  /* [in] */
361             const IID*     rgiidExclude, /* [size_is][unique][in] */
362             SNB            snbExclude, /* [unique][in] */
363             IStorage*    pstgDest);    /* [unique][in] */
364
365 HRESULT WINAPI StorageImpl_MoveElementTo(
366             IStorage*      iface,
367             const OLECHAR* pwcsName,    /* [string][in] */
368             IStorage*      pstgDest,    /* [unique][in] */
369             const OLECHAR* pwcsNewName, /* [string][in] */
370             DWORD            grfFlags);   /* [in] */
371
372 HRESULT WINAPI StorageImpl_Commit(
373             IStorage*      iface,
374             DWORD          grfCommitFlags); /* [in] */
375
376 HRESULT WINAPI StorageImpl_Revert(
377             IStorage*      iface);
378
379 HRESULT WINAPI StorageImpl_DestroyElement(
380             IStorage*      iface,
381             const OLECHAR* pwcsName); /* [string][in] */
382
383 HRESULT WINAPI StorageImpl_SetElementTimes(
384             IStorage*      iface,
385             const OLECHAR* pwcsName, /* [string][in] */
386             const FILETIME*  pctime,   /* [in] */
387             const FILETIME*  patime,   /* [in] */
388             const FILETIME*  pmtime);  /* [in] */
389
390 HRESULT WINAPI StorageImpl_SetStateBits(
391             IStorage*      iface,
392             DWORD          grfStateBits, /* [in] */
393             DWORD          grfMask);     /* [in] */
394
395 HRESULT WINAPI StorageImpl_Stat(IStorage* iface,
396                                 STATSTG*  pstatstg,     /* [out] */
397                                 DWORD     grfStatFlag); /* [in] */
398
399 void StorageImpl_Destroy(
400             StorageBaseImpl* This);
401
402 HRESULT StorageImpl_Construct(
403             StorageImpl* This,
404             HANDLE       hFile,
405             LPCOLESTR    pwcsName,
406             ILockBytes*  pLkbyt,
407             DWORD        openFlags,
408             BOOL         fileBased,
409             BOOL         fileCreate);
410
411 BOOL StorageImpl_ReadBigBlock(
412             StorageImpl* This,
413             ULONG          blockIndex,
414             void*          buffer);
415
416 BOOL StorageImpl_WriteBigBlock(
417             StorageImpl* This,
418             ULONG          blockIndex,
419             void*          buffer);
420
421 void* StorageImpl_GetROBigBlock(
422             StorageImpl* This,
423             ULONG          blockIndex);
424
425 void* StorageImpl_GetBigBlock(
426             StorageImpl* This,
427             ULONG          blockIndex);
428
429 void StorageImpl_ReleaseBigBlock(
430             StorageImpl* This,
431             void*          pBigBlock);
432
433 ULONG StorageImpl_GetNextFreeBigBlock(
434             StorageImpl* This);
435
436 void StorageImpl_FreeBigBlock(
437             StorageImpl* This,
438             ULONG blockIndex);
439
440 HRESULT StorageImpl_GetNextBlockInChain(
441             StorageImpl* This,
442             ULONG blockIndex,
443             ULONG* nextBlockIndex);
444
445 void StorageImpl_SetNextBlockInChain(
446             StorageImpl* This,
447             ULONG blockIndex,
448             ULONG nextBlock);
449
450 HRESULT StorageImpl_LoadFileHeader(
451             StorageImpl* This);
452
453 void StorageImpl_SaveFileHeader(
454             StorageImpl* This);
455
456 BOOL StorageImpl_ReadProperty(
457             StorageImpl* This,
458             ULONG          index,
459             StgProperty*    buffer);
460
461 BOOL StorageImpl_WriteProperty(
462             StorageImpl* This,
463             ULONG          index,
464             StgProperty*   buffer);
465
466 BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
467                       StorageImpl* This,
468                       SmallBlockChainStream** ppsbChain);
469
470 ULONG Storage32Impl_GetNextExtendedBlock(StorageImpl* This,
471                                          ULONG blockIndex);
472
473 void Storage32Impl_AddBlockDepot(StorageImpl* This,
474                                  ULONG blockIndex);
475
476 ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This);
477
478 ULONG Storage32Impl_GetExtDepotBlock(StorageImpl* This,
479                                      ULONG depotIndex);
480
481 void Storage32Impl_SetExtDepotBlock(StorageImpl* This,
482                                     ULONG depotIndex,
483                                     ULONG blockIndex);
484 /****************************************************************************
485  * Storage32InternalImpl definitions.
486  *
487  * Definition of the implementation structure for the IStorage32 interface.
488  * This one implements the IStorage32 interface for storage that are
489  * inside another storage.
490  */
491 struct StorageInternalImpl
492 {
493   struct StorageBaseImpl base;
494
495   /*
496    * There is no specific data for this class.
497    */
498 };
499
500 /*
501  * Method definitions for the Storage32InternalImpl class.
502  */
503 StorageInternalImpl* StorageInternalImpl_Construct(
504             StorageImpl* ancestorStorage,
505             ULONG          rootTropertyIndex);
506
507 void StorageInternalImpl_Destroy(
508             StorageBaseImpl* This);
509
510 HRESULT WINAPI StorageInternalImpl_Commit(
511             IStorage*            iface,
512             DWORD                  grfCommitFlags); /* [in] */
513
514 HRESULT WINAPI StorageInternalImpl_Revert(
515             IStorage*            iface);
516
517
518 /****************************************************************************
519  * IEnumSTATSTGImpl definitions.
520  *
521  * Definition of the implementation structure for the IEnumSTATSTGImpl interface.
522  * This class allows iterating through the content of a storage and to find
523  * specific items inside it.
524  */
525 struct IEnumSTATSTGImpl
526 {
527   IEnumSTATSTGVtbl *lpVtbl;    /* Needs to be the first item in the struct
528                                 * since we want to cast this in a IEnumSTATSTG pointer */
529
530   ULONG          ref;                   /* Reference count */
531   StorageImpl* parentStorage;         /* Reference to the parent storage */
532   ULONG          firstPropertyNode;     /* Index of the root of the storage to enumerate */
533
534   /*
535    * The current implementation of the IEnumSTATSTGImpl class uses a stack
536    * to walk the property sets to get the content of a storage. This stack
537    * is implemented by the following 3 data members
538    */
539   ULONG          stackSize;
540   ULONG          stackMaxSize;
541   ULONG*         stackToVisit;
542
543 #define ENUMSTATSGT_SIZE_INCREMENT 10
544 };
545
546 /*
547  * Method definitions for the IEnumSTATSTGImpl class.
548  */
549 HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
550             IEnumSTATSTG*     iface,
551             REFIID            riid,
552             void**            ppvObject);
553
554 ULONG WINAPI IEnumSTATSTGImpl_AddRef(
555             IEnumSTATSTG*     iface);
556
557 ULONG WINAPI IEnumSTATSTGImpl_Release(
558             IEnumSTATSTG*     iface);
559
560 HRESULT WINAPI IEnumSTATSTGImpl_Next(
561             IEnumSTATSTG*     iface,
562             ULONG             celt,
563             STATSTG*          rgelt,
564             ULONG*            pceltFetched);
565
566 HRESULT WINAPI IEnumSTATSTGImpl_Skip(
567             IEnumSTATSTG*     iface,
568             ULONG             celt);
569
570 HRESULT WINAPI IEnumSTATSTGImpl_Reset(
571             IEnumSTATSTG* iface);
572
573 HRESULT WINAPI IEnumSTATSTGImpl_Clone(
574             IEnumSTATSTG*     iface,
575             IEnumSTATSTG**    ppenum);
576
577 IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(
578             StorageImpl* This,
579             ULONG          firstPropertyNode);
580
581 void IEnumSTATSTGImpl_Destroy(
582             IEnumSTATSTGImpl* This);
583
584 void IEnumSTATSTGImpl_PushSearchNode(
585             IEnumSTATSTGImpl* This,
586             ULONG             nodeToPush);
587
588 ULONG IEnumSTATSTGImpl_PopSearchNode(
589             IEnumSTATSTGImpl* This,
590             BOOL            remove);
591
592 ULONG IEnumSTATSTGImpl_FindProperty(
593             IEnumSTATSTGImpl* This,
594             const OLECHAR*  lpszPropName,
595             StgProperty*      buffer);
596
597 INT IEnumSTATSTGImpl_FindParentProperty(
598   IEnumSTATSTGImpl *This,
599   ULONG             childProperty,
600   StgProperty      *currentProperty,
601   ULONG            *propertyId);
602
603
604 /****************************************************************************
605  * StgStreamImpl definitions.
606  *
607  * This class imlements the IStream32 inteface and represents a stream
608  * located inside a storage object.
609  */
610 struct StgStreamImpl
611 {
612   IStreamVtbl *lpVtbl;  /* Needs to be the first item in the struct
613                          * since we want to cast this in a IStream pointer */
614
615   /*
616    * Reference count
617    */
618   ULONG              ref;
619
620   /*
621    * Storage that is the parent(owner) of the stream
622    */
623   StorageBaseImpl* parentStorage;
624
625   /*
626    * Access mode of this stream.
627    */
628   DWORD grfMode;
629
630   /*
631    * Index of the property that owns (points to) this stream.
632    */
633   ULONG              ownerProperty;
634
635   /*
636    * Helper variable that contains the size of the stream
637    */
638   ULARGE_INTEGER     streamSize;
639
640   /*
641    * This is the current position of the cursor in the stream
642    */
643   ULARGE_INTEGER     currentPosition;
644
645   /*
646    * The information in the stream is represented by a chain of small blocks
647    * or a chain of large blocks. Depending on the case, one of the two
648    * following variabled points to that information.
649    */
650   BlockChainStream*      bigBlockChain;
651   SmallBlockChainStream* smallBlockChain;
652 };
653
654 /*
655  * Method definition for the StgStreamImpl class.
656  */
657 StgStreamImpl* StgStreamImpl_Construct(
658                 StorageBaseImpl* parentStorage,
659     DWORD            grfMode,
660     ULONG            ownerProperty);
661
662 void StgStreamImpl_Destroy(
663                 StgStreamImpl* This);
664
665 void StgStreamImpl_OpenBlockChain(
666                 StgStreamImpl* This);
667
668 HRESULT WINAPI StgStreamImpl_QueryInterface(
669                 IStream*      iface,
670                 REFIID         riid,            /* [in] */
671                 void**         ppvObject);  /* [iid_is][out] */
672
673 ULONG WINAPI StgStreamImpl_AddRef(
674                 IStream*      iface);
675
676 ULONG WINAPI StgStreamImpl_Release(
677                 IStream*      iface);
678
679 HRESULT WINAPI StgStreamImpl_Read(
680                 IStream*      iface,
681                 void*          pv,        /* [length_is][size_is][out] */
682                 ULONG          cb,        /* [in] */
683                 ULONG*         pcbRead);  /* [out] */
684
685 HRESULT WINAPI StgStreamImpl_Write(
686                 IStream*      iface,
687                 const void*    pv,          /* [size_is][in] */
688                 ULONG          cb,          /* [in] */
689                 ULONG*         pcbWritten); /* [out] */
690
691 HRESULT WINAPI StgStreamImpl_Seek(
692                 IStream*      iface,
693                 LARGE_INTEGER   dlibMove,         /* [in] */
694                 DWORD           dwOrigin,         /* [in] */
695                 ULARGE_INTEGER* plibNewPosition); /* [out] */
696
697 HRESULT WINAPI StgStreamImpl_SetSize(
698                 IStream*      iface,
699                 ULARGE_INTEGER  libNewSize);  /* [in] */
700
701 HRESULT WINAPI StgStreamImpl_CopyTo(
702                 IStream*      iface,
703                 IStream*      pstm,         /* [unique][in] */
704                 ULARGE_INTEGER  cb,           /* [in] */
705                 ULARGE_INTEGER* pcbRead,      /* [out] */
706                 ULARGE_INTEGER* pcbWritten);  /* [out] */
707
708 HRESULT WINAPI StgStreamImpl_Commit(
709                 IStream*      iface,
710                 DWORD           grfCommitFlags); /* [in] */
711
712 HRESULT WINAPI StgStreamImpl_Revert(
713                 IStream*  iface);
714
715 HRESULT WINAPI StgStreamImpl_LockRegion(
716                 IStream*     iface,
717                 ULARGE_INTEGER libOffset,   /* [in] */
718                 ULARGE_INTEGER cb,          /* [in] */
719                 DWORD          dwLockType); /* [in] */
720
721 HRESULT WINAPI StgStreamImpl_UnlockRegion(
722                 IStream*     iface,
723                 ULARGE_INTEGER libOffset,   /* [in] */
724                 ULARGE_INTEGER cb,          /* [in] */
725                 DWORD          dwLockType); /* [in] */
726
727 HRESULT WINAPI StgStreamImpl_Stat(
728                 IStream*     iface,
729                 STATSTG*       pstatstg,     /* [out] */
730                 DWORD          grfStatFlag); /* [in] */
731
732 HRESULT WINAPI StgStreamImpl_Clone(
733                 IStream*     iface,
734                 IStream**    ppstm);       /* [out] */
735
736
737 /********************************************************************************
738  * The StorageUtl_ functions are miscelaneous utility functions. Most of which are
739  * abstractions used to read values from file buffers without having to worry
740  * about bit order
741  */
742 void StorageUtl_ReadWord(void* buffer, ULONG offset, WORD* value);
743 void StorageUtl_WriteWord(void* buffer, ULONG offset, WORD value);
744 void StorageUtl_ReadDWord(void* buffer, ULONG offset, DWORD* value);
745 void StorageUtl_WriteDWord(void* buffer, ULONG offset, DWORD value);
746 void StorageUtl_ReadGUID(void* buffer, ULONG offset, GUID* value);
747 void StorageUtl_WriteGUID(void* buffer, ULONG offset, GUID* value);
748 void StorageUtl_CopyPropertyToSTATSTG(STATSTG*     destination,
749                                              StgProperty* source,
750                                              int          statFlags);
751
752 /****************************************************************************
753  * BlockChainStream definitions.
754  *
755  * The BlockChainStream class is a utility class that is used to create an
756  * abstraction of the big block chains in the storage file.
757  */
758 struct BlockChainStream
759 {
760   StorageImpl* parentStorage;
761   ULONG*       headOfStreamPlaceHolder;
762   ULONG        ownerPropertyIndex;
763   ULONG        lastBlockNoInSequence;
764   ULONG        lastBlockNoInSequenceIndex;
765   ULONG        tailIndex;
766   ULONG        numBlocks;
767 };
768
769 /*
770  * Methods for the BlockChainStream class.
771  */
772 BlockChainStream* BlockChainStream_Construct(
773                 StorageImpl* parentStorage,
774                 ULONG*         headOfStreamPlaceHolder,
775                 ULONG          propertyIndex);
776
777 void BlockChainStream_Destroy(
778                 BlockChainStream* This);
779
780 ULONG BlockChainStream_GetHeadOfChain(
781                 BlockChainStream* This);
782
783 BOOL BlockChainStream_ReadAt(
784                 BlockChainStream* This,
785                 ULARGE_INTEGER offset,
786                 ULONG          size,
787                 void*          buffer,
788                 ULONG*         bytesRead);
789
790 BOOL BlockChainStream_WriteAt(
791                 BlockChainStream* This,
792                 ULARGE_INTEGER offset,
793                 ULONG          size,
794                 const void*    buffer,
795                 ULONG*         bytesWritten);
796
797 BOOL BlockChainStream_SetSize(
798                 BlockChainStream* This,
799                 ULARGE_INTEGER    newSize);
800
801 ULARGE_INTEGER BlockChainStream_GetSize(
802     BlockChainStream* This);
803
804 ULONG BlockChainStream_GetCount(
805     BlockChainStream* This);
806
807 /****************************************************************************
808  * SmallBlockChainStream definitions.
809  *
810  * The SmallBlockChainStream class is a utility class that is used to create an
811  * abstraction of the small block chains in the storage file.
812  */
813 struct SmallBlockChainStream
814 {
815   StorageImpl* parentStorage;
816   ULONG          ownerPropertyIndex;
817 };
818
819 /*
820  * Methods of the SmallBlockChainStream class.
821  */
822 SmallBlockChainStream* SmallBlockChainStream_Construct(
823                StorageImpl* parentStorage,
824                ULONG          propertyIndex);
825
826 void SmallBlockChainStream_Destroy(
827                SmallBlockChainStream* This);
828
829 ULONG SmallBlockChainStream_GetHeadOfChain(
830                SmallBlockChainStream* This);
831
832 HRESULT SmallBlockChainStream_GetNextBlockInChain(
833                SmallBlockChainStream* This,
834                ULONG                  blockIndex,
835                ULONG*                 nextBlockIndex);
836
837 void SmallBlockChainStream_SetNextBlockInChain(
838          SmallBlockChainStream* This,
839          ULONG                  blockIndex,
840          ULONG                  nextBlock);
841
842 void SmallBlockChainStream_FreeBlock(
843          SmallBlockChainStream* This,
844          ULONG                  blockIndex);
845
846 ULONG SmallBlockChainStream_GetNextFreeBlock(
847          SmallBlockChainStream* This);
848
849 BOOL SmallBlockChainStream_ReadAt(
850                SmallBlockChainStream* This,
851                ULARGE_INTEGER offset,
852                ULONG          size,
853                void*          buffer,
854                ULONG*         bytesRead);
855
856 BOOL SmallBlockChainStream_WriteAt(
857                SmallBlockChainStream* This,
858                ULARGE_INTEGER offset,
859                ULONG          size,
860                const void*    buffer,
861                ULONG*         bytesWritten);
862
863 BOOL SmallBlockChainStream_SetSize(
864                SmallBlockChainStream* This,
865                ULARGE_INTEGER          newSize);
866
867 ULARGE_INTEGER SmallBlockChainStream_GetSize(
868          SmallBlockChainStream* This);
869
870 ULONG SmallBlockChainStream_GetCount(
871          SmallBlockChainStream* This);
872
873
874 #endif /* __STORAGE32_H__ */