Implemented ProcessComponents.
[wine] / dlls / msi / msipriv.h
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002 Mike McCormack for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_MSI_PRIVATE__
22 #define __WINE_MSI_PRIVATE__
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "msi.h"
29 #include "msiquery.h"
30 #include "objidl.h"
31
32 #define MSI_DATASIZEMASK 0x00ff
33 #define MSITYPE_VALID    0x0100
34 #define MSITYPE_STRING   0x0800
35 #define MSITYPE_NULLABLE 0x1000
36 #define MSITYPE_KEY      0x2000
37
38 #define MSITYPE_BINARY 0x8900
39
40 struct tagMSITABLE;
41 typedef struct tagMSITABLE MSITABLE;
42
43 struct string_table;
44 typedef struct string_table string_table;
45
46 typedef struct tagMSIDATABASE
47 {
48     IStorage *storage;
49     string_table *strings;
50     LPWSTR mode;
51     MSITABLE *first_table, *last_table;
52 } MSIDATABASE;
53
54 struct tagMSIVIEW;
55
56 typedef struct tagMSIVIEWOPS
57 {
58     /*
59      * fetch_int - reads one integer from {row,col} in the table
60      *
61      *  This function should be called after the execute method.
62      *  Data returned by the function should not change until 
63      *   close or delete is called.
64      *  To get a string value, query the database's string table with
65      *   the integer value returned from this function.
66      */
67     UINT (*fetch_int)( struct tagMSIVIEW *, UINT row, UINT col, UINT *val );
68
69     /*
70      * get_int - sets one integer at {row,col} in the table
71      *
72      *  Similar semantics to fetch_int
73      */
74     UINT (*set_int)( struct tagMSIVIEW *, UINT row, UINT col, UINT val );
75
76     /*
77      * Inserts a new, blank row into the database
78      *  *row receives the number of the new row
79      */
80     UINT (*insert_row)( struct tagMSIVIEW *, UINT *row );
81
82     /*
83      * execute - loads the underlying data into memory so it can be read
84      */
85     UINT (*execute)( struct tagMSIVIEW *, MSIHANDLE );
86
87     /*
88      * close - clears the data read by execute from memory
89      */
90     UINT (*close)( struct tagMSIVIEW * );
91
92     /*
93      * get_dimensions - returns the number of rows or columns in a table.
94      *
95      *  The number of rows can only be queried after the execute method
96      *   is called. The number of columns can be queried at any time.
97      */
98     UINT (*get_dimensions)( struct tagMSIVIEW *, UINT *rows, UINT *cols );
99
100     /*
101      * get_column_info - returns the name and type of a specific column
102      *
103      *  The name is HeapAlloc'ed by this function and should be freed by
104      *   the caller.
105      *  The column information can be queried at any time.
106      */
107     UINT (*get_column_info)( struct tagMSIVIEW *, UINT n, LPWSTR *name, UINT *type );
108
109     /*
110      * modify - not yet implemented properly
111      */
112     UINT (*modify)( struct tagMSIVIEW *, MSIMODIFY, MSIHANDLE );
113
114     /*
115      * delete - destroys the structure completely
116      */
117     UINT (*delete)( struct tagMSIVIEW * );
118
119 } MSIVIEWOPS;
120
121 typedef struct tagMSIVIEW
122 {
123     MSIVIEWOPS   *ops;
124 } MSIVIEW;
125
126 typedef struct tagMSISUMMARYINFO
127 {
128     IPropertyStorage *propstg;
129 } MSISUMMARYINFO;
130
131 typedef VOID (*msihandledestructor)( VOID * );
132
133 typedef struct tagMSIHANDLEINFO
134 {
135     UINT magic;
136     UINT type;
137     UINT refcount;
138     msihandledestructor destructor;
139     struct tagMSIHANDLEINFO *next;
140     struct tagMSIHANDLEINFO *prev;
141 } MSIHANDLEINFO;
142
143 typedef struct tagMSIPACKAGE
144 {
145     MSIHANDLE db;
146     struct tagMSIFEATURE *features;
147     UINT loaded_features;
148     struct tagMSIFOLDER  *folders;
149     UINT loaded_folders;
150     struct tagMSICOMPONENT *components;
151     UINT loaded_components;
152     struct tagMSIFILE *files;
153     UINT loaded_files;
154 } MSIPACKAGE;
155
156 #define MSIHANDLETYPE_ANY 0
157 #define MSIHANDLETYPE_DATABASE 1
158 #define MSIHANDLETYPE_SUMMARYINFO 2
159 #define MSIHANDLETYPE_VIEW 3
160 #define MSIHANDLETYPE_RECORD 4
161 #define MSIHANDLETYPE_PACKAGE 5
162
163 #define MSI_MAJORVERSION 1
164 #define MSI_MINORVERSION 10
165 #define MSI_BUILDNUMBER 1029
166
167 #define GUID_SIZE 39
168
169 #define MSIHANDLE_MAGIC 0x4d434923
170 #define MSIMAXHANDLES 0x80
171
172 #define MSISUMINFO_OFFSET 0x30LL
173
174 DEFINE_GUID(CLSID_IMsiServer,   0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
175 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
176 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
177 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
178
179 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
180
181 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
182
183 MSIHANDLE alloc_msihandle(UINT type, UINT extra, msihandledestructor destroy, void **out);
184 void msihandle_addref(MSIHANDLE handle);
185
186 /* add this table to the list of cached tables in the database */
187 extern void add_table(MSIDATABASE *db, MSITABLE *table);
188 extern void remove_table( MSIDATABASE *db, MSITABLE *table );
189 extern void free_table( MSIDATABASE *db, MSITABLE *table );
190 extern void free_cached_tables( MSIDATABASE *db );
191 extern UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table);
192 extern UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table);
193 extern UINT load_string_table( MSIDATABASE *db );
194 extern UINT MSI_CommitTables( MSIDATABASE *db );
195 extern HRESULT init_string_table( IStorage *stg );
196
197
198 /* string table functions */
199 extern BOOL msi_addstring( string_table *st, int string_no, const CHAR *data, int len, UINT refcount );
200 extern BOOL msi_addstringW( string_table *st, int string_no, const WCHAR *data, int len, UINT refcount );
201 extern UINT msi_id2stringW( string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
202 extern UINT msi_id2stringA( string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
203
204 extern LPWSTR MSI_makestring( MSIDATABASE *db, UINT stringid);
205 extern UINT msi_string2idW( string_table *st, LPCWSTR buffer, UINT *id );
206 extern UINT msi_string2idA( string_table *st, LPCSTR str, UINT *id );
207 extern string_table *msi_init_stringtable( int entries, UINT codepage );
208 extern VOID msi_destroy_stringtable( string_table *st );
209 extern UINT msi_string_count( string_table *st );
210 extern UINT msi_id_refcount( string_table *st, UINT i );
211 extern UINT msi_string_totalsize( string_table *st, UINT *last );
212 extern UINT msi_strcmp( string_table *st, UINT lval, UINT rval, UINT *res );
213 extern const WCHAR *msi_string_lookup_id( string_table *st, UINT id );
214 extern UINT msi_string_get_codepage( string_table *st );
215
216
217 UINT VIEW_find_column( MSIVIEW *view, LPWSTR name, UINT *n );
218
219 extern BOOL TABLE_Exists( MSIDATABASE *db, LPWSTR name );
220
221 UINT read_raw_stream_data( MSIHANDLE hdb, LPCWSTR stname,
222                               USHORT **pdata, UINT *psz );
223 UINT ACTION_DoTopLevelINSTALL(MSIHANDLE hPackage, LPCWSTR szPackagePath,
224                               LPCWSTR szCommandLine);
225 void ACTION_remove_tracked_tempfiles(MSIPACKAGE* hPackage);
226
227 /* record internals */
228 extern UINT WINAPI MSI_RecordSetIStream( MSIHANDLE handle, 
229               unsigned int iField, IStream *stm );
230 extern const WCHAR *MSI_RecordGetString( MSIHANDLE handle, unsigned int iField );
231
232
233 /* stream internals */
234 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
235 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
236 extern void enum_stream_names( IStorage *stg );
237
238 BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
239 BOOL squash_guid(LPCWSTR in, LPWSTR out);
240
241 /* UI globals */
242 extern INSTALLUILEVEL gUILevel;
243 extern HWND gUIhwnd;
244 extern INSTALLUI_HANDLERA gUIHandler;
245 extern DWORD gUIFilter;
246 extern LPVOID gUIContext;
247
248 #endif /* __WINE_MSI_PRIVATE__ */