msi: Constify some variables.
[wine] / dlls / msi / msipriv.h
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002-2005 Mike McCormack for CodeWeavers
5  * Copyright 2005 Aric Stewart for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #ifndef __WINE_MSI_PRIVATE__
23 #define __WINE_MSI_PRIVATE__
24
25 #include <stdarg.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "msi.h"
30 #include "msiquery.h"
31 #include "objbase.h"
32 #include "objidl.h"
33 #include "winnls.h"
34 #include "wine/list.h"
35
36 #define MSI_DATASIZEMASK 0x00ff
37 #define MSITYPE_VALID    0x0100
38 #define MSITYPE_LOCALIZABLE 0x200
39 #define MSITYPE_STRING   0x0800
40 #define MSITYPE_NULLABLE 0x1000
41 #define MSITYPE_KEY      0x2000
42
43 /* Word Count masks */
44 #define MSIWORDCOUNT_SHORTFILENAMES     0x0001
45 #define MSIWORDCOUNT_COMPRESSED         0x0002
46 #define MSIWORDCOUNT_ADMINISTRATIVE     0x0004
47 #define MSIWORDCOUNT_PRIVILEGES         0x0008
48
49 /* Install UI level mask for AND operation to exclude flags */
50 #define INSTALLUILEVEL_MASK             0x0007
51
52 #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID))
53
54 struct tagMSITABLE;
55 typedef struct tagMSITABLE MSITABLE;
56
57 struct string_table;
58 typedef struct string_table string_table;
59
60 struct tagMSIOBJECTHDR;
61 typedef struct tagMSIOBJECTHDR MSIOBJECTHDR;
62
63 typedef VOID (*msihandledestructor)( MSIOBJECTHDR * );
64
65 struct tagMSIOBJECTHDR
66 {
67     UINT magic;
68     UINT type;
69     LONG refcount;
70     msihandledestructor destructor;
71 };
72
73 typedef struct tagMSIDATABASE
74 {
75     MSIOBJECTHDR hdr;
76     IStorage *storage;
77     string_table *strings;
78     LPWSTR path;
79     LPWSTR deletefile;
80     LPCWSTR mode;
81     struct list tables;
82     struct list transforms;
83 } MSIDATABASE;
84
85 typedef struct tagMSIVIEW MSIVIEW;
86
87 typedef struct tagMSIQUERY
88 {
89     MSIOBJECTHDR hdr;
90     MSIVIEW *view;
91     UINT row;
92     MSIDATABASE *db;
93     struct list mem;
94 } MSIQUERY;
95
96 /* maybe we can use a Variant instead of doing it ourselves? */
97 typedef struct tagMSIFIELD
98 {
99     UINT type;
100     union
101     {
102         INT iVal;
103         LPWSTR szwVal;
104         IStream *stream;
105     } u;
106 } MSIFIELD;
107
108 typedef struct tagMSIRECORD
109 {
110     MSIOBJECTHDR hdr;
111     UINT count;       /* as passed to MsiCreateRecord */
112     MSIFIELD fields[1]; /* nb. array size is count+1 */
113 } MSIRECORD;
114
115 typedef const struct tagMSICOLUMNHASHENTRY *MSIITERHANDLE;
116
117 typedef struct tagMSIVIEWOPS
118 {
119     /*
120      * fetch_int - reads one integer from {row,col} in the table
121      *
122      *  This function should be called after the execute method.
123      *  Data returned by the function should not change until
124      *   close or delete is called.
125      *  To get a string value, query the database's string table with
126      *   the integer value returned from this function.
127      */
128     UINT (*fetch_int)( struct tagMSIVIEW *, UINT row, UINT col, UINT *val );
129
130     /*
131      * fetch_stream - gets a stream from {row,col} in the table
132      *
133      *  This function is similar to fetch_int, except fetches a
134      *    stream instead of an integer.
135      */
136     UINT (*fetch_stream)( struct tagMSIVIEW *, UINT row, UINT col, IStream **stm );
137
138     /*
139      * set_row - sets values in a row as specified by mask
140      *
141      *  Similar semantics to fetch_int
142      */
143     UINT (*set_row)( struct tagMSIVIEW *, UINT row, MSIRECORD *rec, UINT mask );
144
145     /*
146      * Inserts a new row into the database from the records contents
147      */
148     UINT (*insert_row)( struct tagMSIVIEW *, MSIRECORD *, BOOL temporary );
149
150     /*
151      * execute - loads the underlying data into memory so it can be read
152      */
153     UINT (*execute)( struct tagMSIVIEW *, MSIRECORD * );
154
155     /*
156      * close - clears the data read by execute from memory
157      */
158     UINT (*close)( struct tagMSIVIEW * );
159
160     /*
161      * get_dimensions - returns the number of rows or columns in a table.
162      *
163      *  The number of rows can only be queried after the execute method
164      *   is called. The number of columns can be queried at any time.
165      */
166     UINT (*get_dimensions)( struct tagMSIVIEW *, UINT *rows, UINT *cols );
167
168     /*
169      * get_column_info - returns the name and type of a specific column
170      *
171      *  The name is HeapAlloc'ed by this function and should be freed by
172      *   the caller.
173      *  The column information can be queried at any time.
174      */
175     UINT (*get_column_info)( struct tagMSIVIEW *, UINT n, LPWSTR *name, UINT *type );
176
177     /*
178      * modify - not yet implemented properly
179      */
180     UINT (*modify)( struct tagMSIVIEW *, MSIMODIFY, MSIRECORD * );
181
182     /*
183      * delete - destroys the structure completely
184      */
185     UINT (*delete)( struct tagMSIVIEW * );
186
187     /*
188      * find_matching_rows - iterates through rows that match a value
189      *
190      * If the column type is a string then a string ID should be passed in.
191      *  If the value to be looked up is an integer then no transformation of
192      *  the input value is required, except if the column is a string, in which
193      *  case a string ID should be passed in.
194      * The handle is an input/output parameter that keeps track of the current
195      *  position in the iteration. It must be initialised to zero before the
196      *  first call and continued to be passed in to subsequent calls.
197      */
198     UINT (*find_matching_rows)( struct tagMSIVIEW *, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle );
199 } MSIVIEWOPS;
200
201 struct tagMSIVIEW
202 {
203     MSIOBJECTHDR hdr;
204     const MSIVIEWOPS *ops;
205 };
206
207 struct msi_dialog_tag;
208 typedef struct msi_dialog_tag msi_dialog;
209
210 typedef struct tagMSIPACKAGE
211 {
212     MSIOBJECTHDR hdr;
213     MSIDATABASE *db;
214     struct list components;
215     struct list features;
216     struct list files;
217     struct list tempfiles;
218     struct list folders;
219     LPWSTR ActionFormat;
220     LPWSTR LastAction;
221
222     struct list classes;
223     struct list extensions;
224     struct list progids;
225     struct list mimes;
226     struct list appids;
227
228     struct tagMSISCRIPT *script;
229
230     struct list RunningActions;
231
232     LPWSTR BaseURL;
233     LPWSTR PackagePath;
234     LPWSTR ProductCode;
235
236     UINT CurrentInstallState;
237     msi_dialog *dialog;
238     LPWSTR next_dialog;
239     float center_x;
240     float center_y;
241
242     UINT WordCount;
243
244     struct list subscriptions;
245 } MSIPACKAGE;
246
247 typedef struct tagMSIPREVIEW
248 {
249     MSIOBJECTHDR hdr;
250     MSIPACKAGE *package;
251     msi_dialog *dialog;
252 } MSIPREVIEW;
253
254 #define MSI_MAX_PROPS 20
255
256 typedef struct tagMSISUMMARYINFO
257 {
258     MSIOBJECTHDR hdr;
259     IStorage *storage;
260     DWORD update_count;
261     PROPVARIANT property[MSI_MAX_PROPS];
262 } MSISUMMARYINFO;
263
264 typedef struct tagMSIFEATURE
265 {
266     struct list entry;
267     LPWSTR Feature;
268     LPWSTR Feature_Parent;
269     LPWSTR Title;
270     LPWSTR Description;
271     INT Display;
272     INT Level;
273     LPWSTR Directory;
274     INT Attributes;
275     INSTALLSTATE Installed;
276     INSTALLSTATE ActionRequest;
277     INSTALLSTATE Action;
278     struct list Children;
279     struct list Components;
280     INT Cost;
281 } MSIFEATURE;
282
283 typedef struct tagMSICOMPONENT
284 {
285     struct list entry;
286     DWORD magic;
287     LPWSTR Component;
288     LPWSTR ComponentId;
289     LPWSTR Directory;
290     INT Attributes;
291     LPWSTR Condition;
292     LPWSTR KeyPath;
293     INSTALLSTATE Installed;
294     INSTALLSTATE ActionRequest;
295     INSTALLSTATE Action;
296     BOOL ForceLocalState;
297     BOOL Enabled;
298     INT  Cost;
299     INT  RefCount;
300     LPWSTR FullKeypath;
301     LPWSTR AdvertiseString;
302
303     unsigned int hasAdvertiseFeature:1;
304     unsigned int hasLocalFeature:1;
305     unsigned int hasSourceFeature:1;
306 } MSICOMPONENT;
307
308 typedef struct tagComponentList
309 {
310     struct list entry;
311     MSICOMPONENT *component;
312 } ComponentList;
313
314 typedef struct tagFeatureList
315 {
316     struct list entry;
317     MSIFEATURE *feature;
318 } FeatureList;
319
320 typedef struct tagMSIFOLDER
321 {
322     struct list entry;
323     LPWSTR Directory;
324     LPWSTR Parent;
325     LPWSTR TargetDefault;
326     LPWSTR SourceLongPath;
327     LPWSTR SourceShortPath;
328
329     LPWSTR ResolvedTarget;
330     LPWSTR ResolvedSource;
331     LPWSTR Property;   /* initially set property */
332     INT   State;
333         /* 0 = uninitialized */
334         /* 1 = existing */
335         /* 2 = created remove if empty */
336         /* 3 = created persist if empty */
337     INT   Cost;
338     INT   Space;
339 } MSIFOLDER;
340
341 typedef enum _msi_file_state {
342     msifs_invalid,
343     msifs_missing,
344     msifs_overwrite,
345     msifs_present,
346     msifs_installed,
347     msifs_skipped,
348 } msi_file_state;
349
350 typedef struct tagMSIFILE
351 {
352     struct list entry;
353     LPWSTR File;
354     MSICOMPONENT *Component;
355     LPWSTR FileName;
356     LPWSTR ShortName;
357     LPWSTR LongName;
358     INT FileSize;
359     LPWSTR Version;
360     LPWSTR Language;
361     INT Attributes;
362     INT Sequence;
363     msi_file_state state;
364     LPWSTR  SourcePath;
365     LPWSTR  TargetPath;
366     BOOL IsCompressed;
367 } MSIFILE;
368
369 typedef struct tagMSITEMPFILE
370 {
371     struct list entry;
372     LPWSTR Path;
373 } MSITEMPFILE;
374
375 typedef struct tagMSIAPPID
376 {
377     struct list entry;
378     LPWSTR AppID; /* Primary key */
379     LPWSTR RemoteServerName;
380     LPWSTR LocalServer;
381     LPWSTR ServiceParameters;
382     LPWSTR DllSurrogate;
383     BOOL ActivateAtStorage;
384     BOOL RunAsInteractiveUser;
385 } MSIAPPID;
386
387 typedef struct tagMSIPROGID MSIPROGID;
388
389 typedef struct tagMSICLASS
390 {
391     struct list entry;
392     LPWSTR clsid;     /* Primary Key */
393     LPWSTR Context;   /* Primary Key */
394     MSICOMPONENT *Component;
395     MSIPROGID *ProgID;
396     LPWSTR ProgIDText;
397     LPWSTR Description;
398     MSIAPPID *AppID;
399     LPWSTR FileTypeMask;
400     LPWSTR IconPath;
401     LPWSTR DefInprocHandler;
402     LPWSTR DefInprocHandler32;
403     LPWSTR Argument;
404     MSIFEATURE *Feature;
405     INT Attributes;
406     /* not in the table, set during installation */
407     BOOL Installed;
408 } MSICLASS;
409
410 typedef struct tagMSIMIME MSIMIME;
411
412 typedef struct tagMSIEXTENSION
413 {
414     struct list entry;
415     LPWSTR Extension;  /* Primary Key */
416     MSICOMPONENT *Component;
417     MSIPROGID *ProgID;
418     LPWSTR ProgIDText;
419     MSIMIME *Mime;
420     MSIFEATURE *Feature;
421     /* not in the table, set during installation */
422     BOOL Installed;
423     struct list verbs;
424 } MSIEXTENSION;
425
426 struct tagMSIPROGID
427 {
428     struct list entry;
429     LPWSTR ProgID;  /* Primary Key */
430     MSIPROGID *Parent;
431     MSICLASS *Class;
432     LPWSTR Description;
433     LPWSTR IconPath;
434     /* not in the table, set during installation */
435     BOOL InstallMe;
436     MSIPROGID *CurVer;
437     MSIPROGID *VersionInd;
438 };
439
440 typedef struct tagMSIVERB
441 {
442     struct list entry;
443     LPWSTR Verb;
444     INT Sequence;
445     LPWSTR Command;
446     LPWSTR Argument;
447 } MSIVERB;
448
449 struct tagMSIMIME
450 {
451     struct list entry;
452     LPWSTR ContentType;  /* Primary Key */
453     MSIEXTENSION *Extension;
454     LPWSTR clsid;
455     MSICLASS *Class;
456     /* not in the table, set during installation */
457     BOOL InstallMe;
458 };
459
460 enum SCRIPTS {
461     INSTALL_SCRIPT = 0,
462     COMMIT_SCRIPT = 1,
463     ROLLBACK_SCRIPT = 2,
464     TOTAL_SCRIPTS = 3
465 };
466
467 #define SEQUENCE_UI       0x1
468 #define SEQUENCE_EXEC     0x2
469 #define SEQUENCE_INSTALL  0x10
470
471 typedef struct tagMSISCRIPT
472 {
473     LPWSTR  *Actions[TOTAL_SCRIPTS];
474     UINT    ActionCount[TOTAL_SCRIPTS];
475     BOOL    ExecuteSequenceRun;
476     BOOL    CurrentlyScripting;
477     UINT    InWhatSequence;
478     LPWSTR  *UniqueActions;
479     UINT    UniqueActionsCount;
480 } MSISCRIPT;
481
482 #define MSIHANDLETYPE_ANY 0
483 #define MSIHANDLETYPE_DATABASE 1
484 #define MSIHANDLETYPE_SUMMARYINFO 2
485 #define MSIHANDLETYPE_VIEW 3
486 #define MSIHANDLETYPE_RECORD 4
487 #define MSIHANDLETYPE_PACKAGE 5
488 #define MSIHANDLETYPE_PREVIEW 6
489
490 #define MSI_MAJORVERSION 3
491 #define MSI_MINORVERSION 1
492 #define MSI_BUILDNUMBER 4000
493
494 #define GUID_SIZE 39
495
496 #define MSIHANDLE_MAGIC 0x4d434923
497
498 DEFINE_GUID(CLSID_IMsiServer,   0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
499 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
500 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
501 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
502
503 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
504
505 /* handle unicode/ascii output in the Msi* API functions */
506 typedef struct {
507     BOOL unicode;
508     union {
509        LPSTR a;
510        LPWSTR w;
511     } str;
512 } awstring;
513
514 typedef struct {
515     BOOL unicode;
516     union {
517        LPCSTR a;
518        LPCWSTR w;
519     } str;
520 } awcstring;
521
522 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
523
524 /* msi server interface */
525 extern ITypeLib *get_msi_typelib( LPWSTR *path );
526
527 /* handle functions */
528 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
529 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
530 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
531 extern void msiobj_addref(MSIOBJECTHDR *);
532 extern int msiobj_release(MSIOBJECTHDR *);
533 extern void msiobj_lock(MSIOBJECTHDR *);
534 extern void msiobj_unlock(MSIOBJECTHDR *);
535 extern void msi_free_handle_table(void);
536
537 extern void free_cached_tables( MSIDATABASE *db );
538 extern void msi_free_transforms( MSIDATABASE *db );
539 extern UINT MSI_CommitTables( MSIDATABASE *db );
540
541
542 /* string table functions */
543 enum StringPersistence
544 {
545     StringPersistent = 0,
546     StringNonPersistent = 1
547 };
548
549 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
550 extern UINT msi_id2stringW( string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
551 extern UINT msi_id2stringA( string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
552
553 extern UINT msi_string2idW( string_table *st, LPCWSTR buffer, UINT *id );
554 extern UINT msi_string2idA( string_table *st, LPCSTR str, UINT *id );
555 extern VOID msi_destroy_stringtable( string_table *st );
556 extern UINT msi_strcmp( string_table *st, UINT lval, UINT rval, UINT *res );
557 extern const WCHAR *msi_string_lookup_id( string_table *st, UINT id );
558 extern HRESULT msi_init_string_table( IStorage *stg );
559 extern string_table *msi_load_string_table( IStorage *stg );
560 extern UINT msi_save_string_table( string_table *st, IStorage *storage );
561
562
563 extern BOOL TABLE_Exists( MSIDATABASE *db, LPCWSTR name );
564 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
565
566 extern UINT read_raw_stream_data( MSIDATABASE*, LPCWSTR stname,
567                                   USHORT **pdata, UINT *psz );
568 extern UINT read_stream_data( IStorage *stg, LPCWSTR stname,
569                               USHORT **pdata, UINT *psz );
570 extern UINT write_stream_data( IStorage *stg, LPCWSTR stname,
571                                LPVOID data, UINT sz, BOOL bTable );
572
573 /* transform functions */
574 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
575 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
576                  LPCWSTR szTransformFile, int iErrorCond );
577 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
578
579 /* action internals */
580 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
581 extern void ACTION_free_package_structures( MSIPACKAGE* );
582 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
583 extern UINT ACTION_ForceReboot(MSIPACKAGE *package);
584 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
585 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
586
587 /* record internals */
588 extern UINT MSI_RecordSetIStream( MSIRECORD *, unsigned int, IStream *);
589 extern UINT MSI_RecordGetIStream( MSIRECORD *, unsigned int, IStream **);
590 extern const WCHAR *MSI_RecordGetString( const MSIRECORD *, unsigned int );
591 extern MSIRECORD *MSI_CreateRecord( unsigned int );
592 extern UINT MSI_RecordSetInteger( MSIRECORD *, unsigned int, int );
593 extern UINT MSI_RecordSetStringW( MSIRECORD *, unsigned int, LPCWSTR );
594 extern UINT MSI_RecordSetStringA( MSIRECORD *, unsigned int, LPCSTR );
595 extern BOOL MSI_RecordIsNull( MSIRECORD *, unsigned int );
596 extern UINT MSI_RecordGetStringW( MSIRECORD * , unsigned int, LPWSTR, DWORD *);
597 extern UINT MSI_RecordGetStringA( MSIRECORD *, unsigned int, LPSTR, DWORD *);
598 extern int MSI_RecordGetInteger( MSIRECORD *, unsigned int );
599 extern UINT MSI_RecordReadStream( MSIRECORD *, unsigned int, char *, DWORD *);
600 extern unsigned int MSI_RecordGetFieldCount( const MSIRECORD *rec );
601 extern UINT MSI_RecordSetStream( MSIRECORD *, unsigned int, IStream * );
602 extern UINT MSI_RecordDataSize( MSIRECORD *, unsigned int );
603 extern UINT MSI_RecordStreamToFile( MSIRECORD *, unsigned int, LPCWSTR );
604 extern UINT MSI_RecordCopyField( MSIRECORD *, unsigned int, MSIRECORD *, unsigned int );
605
606 /* stream internals */
607 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
608 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
609 extern void enum_stream_names( IStorage *stg );
610 extern BOOL decode_streamname(LPWSTR in, LPWSTR out);
611 extern LPWSTR encode_streamname(BOOL bTable, LPCWSTR in);
612
613 /* database internals */
614 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
615 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
616 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
617 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
618 extern UINT MSI_IterateRecords( MSIQUERY *, DWORD *, record_func, LPVOID );
619 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
620 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
621 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
622 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
623
624 /* view internals */
625 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
626 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
627 extern UINT MSI_ViewClose( MSIQUERY* );
628 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
629 extern UINT MSI_ViewModify( MSIQUERY *, MSIMODIFY, MSIRECORD * );
630 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
631
632
633 /* install internals */
634 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
635
636 /* package internals */
637 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR );
638 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE ** );
639 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
640 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
641 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
642 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, DWORD * );
643 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, DWORD* );
644 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
645 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
646 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
647 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
648 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
649
650 /* for deformating */
651 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, DWORD * );
652 extern UINT MSI_FormatRecordA( MSIPACKAGE *, MSIRECORD *, LPSTR, DWORD * );
653
654 /* registry data encoding/decoding functions */
655 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
656 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
657 extern BOOL encode_base85_guid(GUID *,LPWSTR);
658 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
659 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
660 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
661 extern UINT MSIREG_OpenFeatures(HKEY* key);
662 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
663 extern UINT MSIREG_OpenComponents(HKEY* key);
664 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
665 extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
666 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
667 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
668 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
669 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
670 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
671
672 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
673 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
674
675 extern DWORD msi_version_str_to_dword(LPCWSTR p);
676 extern LPWSTR msi_version_dword_to_str(DWORD version);
677
678 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
679 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
680 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
681 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
682
683 /* msi dialog interface */
684 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
685 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
686 extern UINT msi_dialog_run_message_loop( msi_dialog* );
687 extern void msi_dialog_end_dialog( msi_dialog* );
688 extern void msi_dialog_check_messages( HANDLE );
689 extern void msi_dialog_do_preview( msi_dialog* );
690 extern void msi_dialog_destroy( msi_dialog* );
691 extern BOOL msi_dialog_register_class( void );
692 extern void msi_dialog_unregister_class( void );
693 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
694 extern UINT msi_dialog_reset( msi_dialog *dialog );
695 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
696 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
697 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
698 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
699
700 /* preview */
701 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
702 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
703
704 /* summary information */
705 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
706 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
707 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
708
709 /* undocumented functions */
710 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
711 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD * );
712 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, DWORD * );
713 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
714 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
715
716 /* UI globals */
717 extern INSTALLUILEVEL gUILevel;
718 extern HWND gUIhwnd;
719 extern INSTALLUI_HANDLERA gUIHandlerA;
720 extern INSTALLUI_HANDLERW gUIHandlerW;
721 extern DWORD gUIFilter;
722 extern LPVOID gUIContext;
723 extern WCHAR gszLogFile[MAX_PATH];
724 extern HINSTANCE msi_hInstance;
725
726 /* action related functions */
727 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force);
728 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action);
729 extern void ACTION_FinishCustomActions( const MSIPACKAGE* package);
730 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, BOOL execute);
731
732 static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
733 {
734     feature->ActionRequest = state;
735     feature->Action = state;
736 }
737
738 static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
739 {
740     comp->ActionRequest = state;
741     comp->Action = state;
742 }
743
744 /* actions in other modules */
745 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
746 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
747 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
748 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
749 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
750 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
751 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
752 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
753 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
754 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
755
756 /* Helpers */
757 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
758 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
759 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
760 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
761 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
762                       BOOL set_prop, BOOL load_prop, MSIFOLDER **folder);
763 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
764 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
765 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
766 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
767 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
768 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
769 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
770 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
771 extern LPWSTR build_directory_name(DWORD , ...);
772 extern BOOL create_full_pathW(const WCHAR *path);
773 extern BOOL ACTION_VerifyComponentForAction(const MSICOMPONENT*, INSTALLSTATE);
774 extern BOOL ACTION_VerifyFeatureForAction(const MSIFEATURE*, INSTALLSTATE);
775 extern void reduce_to_longfilename(WCHAR*);
776 extern void reduce_to_shortfilename(WCHAR*);
777 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
778 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
779 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
780 extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
781 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
782 extern UINT msi_create_component_directories( MSIPACKAGE *package );
783 extern void msi_ui_error( DWORD msg_id, DWORD type );
784
785 /* control event stuff */
786 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
787                                       MSIRECORD *data);
788 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
789 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
790 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
791                                       LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
792 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
793                                       LPCWSTR control, LPCWSTR attribute );
794
795 /* OLE automation */
796 extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
797 extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
798 extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
799
800 /* Scripting */
801 extern DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function, LPCWSTR action);
802
803 /* User Interface messages from the actions */
804 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
805 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
806
807 /* string consts use a number of places  and defined in helpers.c*/
808 extern const WCHAR cszSourceDir[];
809 extern const WCHAR cszSOURCEDIR[];
810 extern const WCHAR szProductCode[];
811 extern const WCHAR cszRootDrive[];
812 extern const WCHAR cszbs[];
813
814 /* memory allocation macro functions */
815 static inline void *msi_alloc( size_t len )
816 {
817     return HeapAlloc( GetProcessHeap(), 0, len );
818 }
819
820 static inline void *msi_alloc_zero( size_t len )
821 {
822     return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
823 }
824
825 static inline void *msi_realloc( void *mem, size_t len )
826 {
827     return HeapReAlloc( GetProcessHeap(), 0, mem, len );
828 }
829
830 static inline void *msi_realloc_zero( void *mem, size_t len )
831 {
832     return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
833 }
834
835 static inline BOOL msi_free( void *mem )
836 {
837     return HeapFree( GetProcessHeap(), 0, mem );
838 }
839
840 static inline char *strdupWtoA( LPCWSTR str )
841 {
842     LPSTR ret = NULL;
843     DWORD len;
844
845     if (!str) return ret;
846     len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
847     ret = msi_alloc( len );
848     if (ret)
849         WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
850     return ret;
851 }
852
853 static inline LPWSTR strdupAtoW( LPCSTR str )
854 {
855     LPWSTR ret = NULL;
856     DWORD len;
857
858     if (!str) return ret;
859     len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
860     ret = msi_alloc( len * sizeof(WCHAR) );
861     if (ret)
862         MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
863     return ret;
864 }
865
866 static inline LPWSTR strdupW( LPCWSTR src )
867 {
868     LPWSTR dest;
869     if (!src) return NULL;
870     dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
871     if (dest)
872         lstrcpyW(dest, src);
873     return dest;
874 }
875
876 #endif /* __WINE_MSI_PRIVATE__ */