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