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