msvcrt: Replace inline static with static inline.
[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 * );
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 #define PROPERTY_HASH_SIZE 67
211
212 typedef struct tagMSIPACKAGE
213 {
214     MSIOBJECTHDR hdr;
215     MSIDATABASE *db;
216     struct list components;
217     struct list features;
218     struct list files;
219     struct list tempfiles;
220     struct list folders;
221     LPWSTR ActionFormat;
222     LPWSTR LastAction;
223
224     struct list classes;
225     struct list extensions;
226     struct list progids;
227     struct list mimes;
228     struct list appids;
229
230     struct tagMSISCRIPT *script;
231
232     struct list RunningActions;
233
234     LPWSTR BaseURL;
235     LPWSTR PackagePath;
236     LPWSTR ProductCode;
237
238     UINT CurrentInstallState;
239     msi_dialog *dialog;
240     LPWSTR next_dialog;
241     float center_x;
242     float center_y;
243
244     UINT WordCount;
245
246     struct list props[PROPERTY_HASH_SIZE];
247
248     struct list subscriptions;
249 } MSIPACKAGE;
250
251 typedef struct tagMSIPREVIEW
252 {
253     MSIOBJECTHDR hdr;
254     MSIPACKAGE *package;
255     msi_dialog *dialog;
256 } MSIPREVIEW;
257
258 #define MSI_MAX_PROPS 20
259
260 typedef struct tagMSISUMMARYINFO
261 {
262     MSIOBJECTHDR hdr;
263     IStorage *storage;
264     DWORD update_count;
265     PROPVARIANT property[MSI_MAX_PROPS];
266 } MSISUMMARYINFO;
267
268 typedef struct tagMSIFEATURE
269 {
270     struct list entry;
271     LPWSTR Feature;
272     LPWSTR Feature_Parent;
273     LPWSTR Title;
274     LPWSTR Description;
275     INT Display;
276     INT Level;
277     LPWSTR Directory;
278     INT Attributes;
279     INSTALLSTATE Installed;
280     INSTALLSTATE ActionRequest;
281     INSTALLSTATE Action;
282     struct list Children;
283     struct list Components;
284     INT Cost;
285 } MSIFEATURE;
286
287 typedef struct tagMSICOMPONENT
288 {
289     struct list entry;
290     DWORD magic;
291     LPWSTR Component;
292     LPWSTR ComponentId;
293     LPWSTR Directory;
294     INT Attributes;
295     LPWSTR Condition;
296     LPWSTR KeyPath;
297     INSTALLSTATE Installed;
298     INSTALLSTATE ActionRequest;
299     INSTALLSTATE Action;
300     BOOL ForceLocalState;
301     BOOL Enabled;
302     INT  Cost;
303     INT  RefCount;
304     LPWSTR FullKeypath;
305     LPWSTR AdvertiseString;
306
307     int hasAdvertiseFeature:1;
308     int hasLocalFeature:1;
309     int hasSourceFeature:1;
310 } MSICOMPONENT;
311
312 typedef struct tagComponentList
313 {
314     struct list entry;
315     MSICOMPONENT *component;
316 } ComponentList;
317
318 typedef struct tagFeatureList
319 {
320     struct list entry;
321     MSIFEATURE *feature;
322 } FeatureList;
323
324 typedef struct tagMSIFOLDER
325 {
326     struct list entry;
327     LPWSTR Directory;
328     LPWSTR Parent;
329     LPWSTR TargetDefault;
330     LPWSTR SourceLongPath;
331     LPWSTR SourceShortPath;
332
333     LPWSTR ResolvedTarget;
334     LPWSTR ResolvedSource;
335     LPWSTR Property;   /* initially set property */
336     INT   State;
337         /* 0 = uninitialized */
338         /* 1 = existing */
339         /* 2 = created remove if empty */
340         /* 3 = created persist if empty */
341     INT   Cost;
342     INT   Space;
343 } MSIFOLDER;
344
345 typedef enum _msi_file_state {
346     msifs_invalid,
347     msifs_missing,
348     msifs_overwrite,
349     msifs_present,
350     msifs_installed,
351     msifs_skipped,
352 } msi_file_state;
353
354 typedef struct tagMSIFILE
355 {
356     struct list entry;
357     LPWSTR File;
358     MSICOMPONENT *Component;
359     LPWSTR FileName;
360     LPWSTR ShortName;
361     LPWSTR LongName;
362     INT FileSize;
363     LPWSTR Version;
364     LPWSTR Language;
365     INT Attributes;
366     INT Sequence;
367     msi_file_state state;
368     LPWSTR  SourcePath;
369     LPWSTR  TargetPath;
370     BOOL IsCompressed;
371 } MSIFILE;
372
373 typedef struct tagMSITEMPFILE
374 {
375     struct list entry;
376     LPWSTR Path;
377 } MSITEMPFILE;
378
379 typedef struct tagMSIAPPID
380 {
381     struct list entry;
382     LPWSTR AppID; /* Primary key */
383     LPWSTR RemoteServerName;
384     LPWSTR LocalServer;
385     LPWSTR ServiceParameters;
386     LPWSTR DllSurrogate;
387     BOOL ActivateAtStorage;
388     BOOL RunAsInteractiveUser;
389 } MSIAPPID;
390
391 typedef struct tagMSIPROGID MSIPROGID;
392
393 typedef struct tagMSICLASS
394 {
395     struct list entry;
396     LPWSTR clsid;     /* Primary Key */
397     LPWSTR Context;   /* Primary Key */
398     MSICOMPONENT *Component;
399     MSIPROGID *ProgID;
400     LPWSTR ProgIDText;
401     LPWSTR Description;
402     MSIAPPID *AppID;
403     LPWSTR FileTypeMask;
404     LPWSTR IconPath;
405     LPWSTR DefInprocHandler;
406     LPWSTR DefInprocHandler32;
407     LPWSTR Argument;
408     MSIFEATURE *Feature;
409     INT Attributes;
410     /* not in the table, set during installation */
411     BOOL Installed;
412 } MSICLASS;
413
414 typedef struct tagMSIMIME MSIMIME;
415
416 typedef struct tagMSIEXTENSION
417 {
418     struct list entry;
419     LPWSTR Extension;  /* Primary Key */
420     MSICOMPONENT *Component;
421     MSIPROGID *ProgID;
422     LPWSTR ProgIDText;
423     MSIMIME *Mime;
424     MSIFEATURE *Feature;
425     /* not in the table, set during installation */
426     BOOL Installed;
427     struct list verbs;
428 } MSIEXTENSION;
429
430 struct tagMSIPROGID
431 {
432     struct list entry;
433     LPWSTR ProgID;  /* Primary Key */
434     MSIPROGID *Parent;
435     MSICLASS *Class;
436     LPWSTR Description;
437     LPWSTR IconPath;
438     /* not in the table, set during installation */
439     BOOL InstallMe;
440     MSIPROGID *CurVer;
441     MSIPROGID *VersionInd;
442 };
443
444 typedef struct tagMSIVERB
445 {
446     struct list entry;
447     LPWSTR Verb;
448     INT Sequence;
449     LPWSTR Command;
450     LPWSTR Argument;
451 } MSIVERB;
452
453 struct tagMSIMIME
454 {
455     struct list entry;
456     LPWSTR ContentType;  /* Primary Key */
457     MSIEXTENSION *Extension;
458     LPWSTR clsid;
459     MSICLASS *Class;
460     /* not in the table, set during installation */
461     BOOL InstallMe;
462 };
463
464 enum SCRIPTS {
465     INSTALL_SCRIPT = 0,
466     COMMIT_SCRIPT = 1,
467     ROLLBACK_SCRIPT = 2,
468     TOTAL_SCRIPTS = 3
469 };
470
471 #define SEQUENCE_UI       0x1
472 #define SEQUENCE_EXEC     0x2
473 #define SEQUENCE_INSTALL  0x10
474
475 typedef struct tagMSISCRIPT
476 {
477     LPWSTR  *Actions[TOTAL_SCRIPTS];
478     UINT    ActionCount[TOTAL_SCRIPTS];
479     BOOL    ExecuteSequenceRun;
480     BOOL    CurrentlyScripting;
481     UINT    InWhatSequence;
482     LPWSTR  *UniqueActions;
483     UINT    UniqueActionsCount;
484 } MSISCRIPT;
485
486 #define MSIHANDLETYPE_ANY 0
487 #define MSIHANDLETYPE_DATABASE 1
488 #define MSIHANDLETYPE_SUMMARYINFO 2
489 #define MSIHANDLETYPE_VIEW 3
490 #define MSIHANDLETYPE_RECORD 4
491 #define MSIHANDLETYPE_PACKAGE 5
492 #define MSIHANDLETYPE_PREVIEW 6
493
494 #define MSI_MAJORVERSION 3
495 #define MSI_MINORVERSION 1
496 #define MSI_BUILDNUMBER 4000
497
498 #define GUID_SIZE 39
499
500 #define MSIHANDLE_MAGIC 0x4d434923
501
502 DEFINE_GUID(CLSID_IMsiServer,   0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
503 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
504 DEFINE_GUID(CLSID_IMsiServerX2, 0x000C1090,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
505 DEFINE_GUID(CLSID_IMsiServerX3, 0x000C1094,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
506
507 DEFINE_GUID(CLSID_IMsiServerMessage, 0x000C101D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
508
509 /* handle unicode/ascii output in the Msi* API functions */
510 typedef struct {
511     BOOL unicode;
512     union {
513        LPSTR a;
514        LPWSTR w;
515     } str;
516 } awstring;
517
518 typedef struct {
519     BOOL unicode;
520     union {
521        LPCSTR a;
522        LPCWSTR w;
523     } str;
524 } awcstring;
525
526 UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
527
528 /* msi server interface */
529 extern ITypeLib *get_msi_typelib( LPWSTR *path );
530
531 /* handle functions */
532 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
533 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
534 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
535 extern void msiobj_addref(MSIOBJECTHDR *);
536 extern int msiobj_release(MSIOBJECTHDR *);
537 extern void msiobj_lock(MSIOBJECTHDR *);
538 extern void msiobj_unlock(MSIOBJECTHDR *);
539 extern void msi_free_handle_table(void);
540
541 extern void free_cached_tables( MSIDATABASE *db );
542 extern void msi_free_transforms( MSIDATABASE *db );
543 extern string_table *load_string_table( IStorage *stg );
544 extern UINT MSI_CommitTables( MSIDATABASE *db );
545 extern HRESULT init_string_table( IStorage *stg );
546
547
548 /* string table functions */
549 extern BOOL msi_addstring( string_table *st, UINT string_no, const CHAR *data, int len, UINT refcount );
550 extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount );
551 extern UINT msi_id2stringW( string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
552 extern UINT msi_id2stringA( string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
553
554 extern UINT msi_string2idW( string_table *st, LPCWSTR buffer, UINT *id );
555 extern UINT msi_string2idA( string_table *st, LPCSTR str, UINT *id );
556 extern string_table *msi_init_stringtable( int entries, UINT codepage );
557 extern VOID msi_destroy_stringtable( string_table *st );
558 extern UINT msi_string_count( string_table *st );
559 extern UINT msi_id_refcount( string_table *st, UINT i );
560 extern UINT msi_string_totalsize( string_table *st, UINT *datasize, UINT *poolsize );
561 extern UINT msi_strcmp( string_table *st, UINT lval, UINT rval, UINT *res );
562 extern const WCHAR *msi_string_lookup_id( string_table *st, UINT id );
563 extern UINT msi_string_get_codepage( string_table *st );
564
565
566 extern BOOL TABLE_Exists( MSIDATABASE *db, LPWSTR name );
567 extern MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table );
568
569 extern UINT read_raw_stream_data( MSIDATABASE*, LPCWSTR stname,
570                               USHORT **pdata, UINT *psz );
571
572 /* transform functions */
573 extern UINT msi_table_apply_transform( MSIDATABASE *db, IStorage *stg );
574 extern UINT MSI_DatabaseApplyTransformW( MSIDATABASE *db,
575                  LPCWSTR szTransformFile, int iErrorCond );
576 extern void append_storage_to_db( MSIDATABASE *db, IStorage *stg );
577
578 /* action internals */
579 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR );
580 extern void ACTION_free_package_structures( MSIPACKAGE* );
581 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
582 extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode );
583 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package );
584
585 /* record internals */
586 extern UINT MSI_RecordSetIStream( MSIRECORD *, unsigned int, IStream *);
587 extern UINT MSI_RecordGetIStream( MSIRECORD *, unsigned int, IStream **);
588 extern const WCHAR *MSI_RecordGetString( MSIRECORD *, unsigned int );
589 extern MSIRECORD *MSI_CreateRecord( unsigned int );
590 extern UINT MSI_RecordSetInteger( MSIRECORD *, unsigned int, int );
591 extern UINT MSI_RecordSetStringW( MSIRECORD *, unsigned int, LPCWSTR );
592 extern UINT MSI_RecordSetStringA( MSIRECORD *, unsigned int, LPCSTR );
593 extern BOOL MSI_RecordIsNull( MSIRECORD *, unsigned int );
594 extern UINT MSI_RecordGetStringW( MSIRECORD * , unsigned int, LPWSTR, DWORD *);
595 extern UINT MSI_RecordGetStringA( MSIRECORD *, unsigned int, LPSTR, DWORD *);
596 extern int MSI_RecordGetInteger( MSIRECORD *, unsigned int );
597 extern UINT MSI_RecordReadStream( MSIRECORD *, unsigned int, char *, DWORD *);
598 extern unsigned int MSI_RecordGetFieldCount( MSIRECORD *rec );
599 extern UINT MSI_RecordSetStreamW( MSIRECORD *, unsigned int, LPCWSTR );
600 extern UINT MSI_RecordSetStreamA( MSIRECORD *, unsigned int, LPCSTR );
601 extern UINT MSI_RecordDataSize( MSIRECORD *, unsigned int );
602 extern UINT MSI_RecordStreamToFile( MSIRECORD *, unsigned int, LPCWSTR );
603 extern UINT MSI_RecordCopyField( MSIRECORD *, unsigned int, MSIRECORD *, unsigned int );
604
605 /* stream internals */
606 extern UINT get_raw_stream( MSIHANDLE hdb, LPCWSTR stname, IStream **stm );
607 extern UINT db_get_raw_stream( MSIDATABASE *db, LPCWSTR stname, IStream **stm );
608 extern void enum_stream_names( IStorage *stg );
609
610 /* database internals */
611 extern UINT MSI_OpenDatabaseW( LPCWSTR, LPCWSTR, MSIDATABASE ** );
612 extern UINT MSI_DatabaseOpenViewW(MSIDATABASE *, LPCWSTR, MSIQUERY ** );
613 extern UINT MSI_OpenQuery( MSIDATABASE *, MSIQUERY **, LPCWSTR, ... );
614 typedef UINT (*record_func)( MSIRECORD *, LPVOID );
615 extern UINT MSI_IterateRecords( MSIQUERY *, DWORD *, record_func, LPVOID );
616 extern MSIRECORD *MSI_QueryGetRecord( MSIDATABASE *db, LPCWSTR query, ... );
617 extern UINT MSI_DatabaseImport( MSIDATABASE *, LPCWSTR, LPCWSTR );
618 extern UINT MSI_DatabaseExport( MSIDATABASE *, LPCWSTR, LPCWSTR, LPCWSTR );
619 extern UINT MSI_DatabaseGetPrimaryKeys( MSIDATABASE *, LPCWSTR, MSIRECORD ** );
620
621 /* view internals */
622 extern UINT MSI_ViewExecute( MSIQUERY*, MSIRECORD * );
623 extern UINT MSI_ViewFetch( MSIQUERY*, MSIRECORD ** );
624 extern UINT MSI_ViewClose( MSIQUERY* );
625 extern UINT MSI_ViewGetColumnInfo(MSIQUERY *, MSICOLINFO, MSIRECORD **);
626 extern UINT VIEW_find_column( MSIVIEW *, LPCWSTR, UINT * );
627
628
629 /* install internals */
630 extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel );
631
632 /* package internals */
633 extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPWSTR );
634 extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE ** );
635 extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
636 extern UINT MSI_SetPropertyW( MSIPACKAGE *, LPCWSTR, LPCWSTR );
637 extern INT MSI_ProcessMessage( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * );
638 extern UINT MSI_GetPropertyW( MSIPACKAGE *, LPCWSTR, LPWSTR, DWORD * );
639 extern UINT MSI_GetPropertyA(MSIPACKAGE *, LPCSTR, LPSTR, DWORD* );
640 extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
641 extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
642 extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
643 extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
644 extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
645
646 /* for deformating */
647 extern UINT MSI_FormatRecordW( MSIPACKAGE *, MSIRECORD *, LPWSTR, DWORD * );
648 extern UINT MSI_FormatRecordA( MSIPACKAGE *, MSIRECORD *, LPSTR, DWORD * );
649
650 /* registry data encoding/decoding functions */
651 extern BOOL unsquash_guid(LPCWSTR in, LPWSTR out);
652 extern BOOL squash_guid(LPCWSTR in, LPWSTR out);
653 extern BOOL encode_base85_guid(GUID *,LPWSTR);
654 extern BOOL decode_base85_guid(LPCWSTR,GUID*);
655 extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
656 extern UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
657 extern UINT MSIREG_OpenFeatures(HKEY* key);
658 extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
659 extern UINT MSIREG_OpenComponents(HKEY* key);
660 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
661 extern UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
662 extern UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
663 extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
664 extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
665 extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
666 extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
667
668 extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );
669 extern BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val);
670
671 extern DWORD msi_version_str_to_dword(LPCWSTR p);
672 extern LPWSTR msi_version_dword_to_str(DWORD version);
673
674 extern LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
675 extern LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value );
676 extern LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val );
677 extern LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val );
678
679 /* msi dialog interface */
680 typedef UINT (*msi_dialog_event_handler)( MSIPACKAGE*, LPCWSTR, LPCWSTR, msi_dialog* );
681 extern msi_dialog *msi_dialog_create( MSIPACKAGE*, LPCWSTR, msi_dialog*, msi_dialog_event_handler );
682 extern UINT msi_dialog_run_message_loop( msi_dialog* );
683 extern void msi_dialog_end_dialog( msi_dialog* );
684 extern void msi_dialog_check_messages( HANDLE );
685 extern void msi_dialog_do_preview( msi_dialog* );
686 extern void msi_dialog_destroy( msi_dialog* );
687 extern BOOL msi_dialog_register_class( void );
688 extern void msi_dialog_unregister_class( void );
689 extern void msi_dialog_handle_event( msi_dialog*, LPCWSTR, LPCWSTR, MSIRECORD * );
690 extern UINT msi_dialog_reset( msi_dialog *dialog );
691 extern UINT msi_dialog_directorylist_up( msi_dialog *dialog );
692 extern msi_dialog *msi_dialog_get_parent( msi_dialog *dialog );
693 extern LPWSTR msi_dialog_get_name( msi_dialog *dialog );
694 extern UINT msi_spawn_error_dialog( MSIPACKAGE*, LPWSTR, LPWSTR );
695
696 /* preview */
697 extern MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE * );
698 extern UINT MSI_PreviewDialogW( MSIPREVIEW *, LPCWSTR );
699
700 /* summary information */
701 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
702 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
703 extern LPWSTR msi_get_suminfo_product( IStorage *stg );
704
705 /* undocumented functions */
706 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
707 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR, LPWSTR, LPWSTR, LPWSTR, DWORD * );
708 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR, LPSTR, LPSTR, LPSTR, DWORD * );
709 LANGID WINAPI MsiLoadStringW( MSIHANDLE, UINT, LPWSTR, int, LANGID );
710 LANGID WINAPI MsiLoadStringA( MSIHANDLE, UINT, LPSTR, int, LANGID );
711
712 /* UI globals */
713 extern INSTALLUILEVEL gUILevel;
714 extern HWND gUIhwnd;
715 extern INSTALLUI_HANDLERA gUIHandlerA;
716 extern INSTALLUI_HANDLERW gUIHandlerW;
717 extern DWORD gUIFilter;
718 extern LPVOID gUIContext;
719 extern WCHAR gszLogFile[MAX_PATH];
720 extern HINSTANCE msi_hInstance;
721
722 /* action related functions */
723 extern UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, BOOL force);
724 extern UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action);
725 extern void ACTION_FinishCustomActions( MSIPACKAGE* package);
726 extern UINT ACTION_CustomAction(MSIPACKAGE *package,const WCHAR *action, BOOL execute);
727
728 static inline void msi_feature_set_state( MSIFEATURE *feature, INSTALLSTATE state )
729 {
730     feature->ActionRequest = state;
731     feature->Action = state;
732 }
733
734 static inline void msi_component_set_state( MSICOMPONENT *comp, INSTALLSTATE state )
735 {
736     comp->ActionRequest = state;
737     comp->Action = state;
738 }
739
740 /* actions in other modules */
741 extern UINT ACTION_AppSearch(MSIPACKAGE *package);
742 extern UINT ACTION_FindRelatedProducts(MSIPACKAGE *package);
743 extern UINT ACTION_InstallFiles(MSIPACKAGE *package);
744 extern UINT ACTION_RemoveFiles(MSIPACKAGE *package);
745 extern UINT ACTION_DuplicateFiles(MSIPACKAGE *package);
746 extern UINT ACTION_RegisterClassInfo(MSIPACKAGE *package);
747 extern UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package);
748 extern UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package);
749 extern UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package);
750 extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
751
752 /* Helpers */
753 extern DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data );
754 extern LPWSTR msi_dup_record_field(MSIRECORD *row, INT index);
755 extern LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop);
756 extern int msi_get_property_int( MSIPACKAGE *package, LPCWSTR prop, int def );
757 extern LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
758                       BOOL set_prop, MSIFOLDER **folder);
759 extern MSICOMPONENT *get_loaded_component( MSIPACKAGE* package, LPCWSTR Component );
760 extern MSIFEATURE *get_loaded_feature( MSIPACKAGE* package, LPCWSTR Feature );
761 extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
762 extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
763 extern int track_tempfile(MSIPACKAGE *package, LPCWSTR path);
764 extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
765 extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
766 extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
767 extern LPWSTR build_directory_name(DWORD , ...);
768 extern BOOL create_full_pathW(const WCHAR *path);
769 extern BOOL ACTION_VerifyComponentForAction(MSICOMPONENT*, INSTALLSTATE);
770 extern BOOL ACTION_VerifyFeatureForAction(MSIFEATURE*, INSTALLSTATE);
771 extern void reduce_to_longfilename(WCHAR*);
772 extern void reduce_to_shortfilename(WCHAR*);
773 extern LPWSTR create_component_advertise_string(MSIPACKAGE*, MSICOMPONENT*, LPCWSTR);
774 extern void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature);
775 extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
776 extern BOOL check_unique_action(MSIPACKAGE *, LPCWSTR);
777 extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
778 extern UINT msi_create_component_directories( MSIPACKAGE *package );
779 extern void msi_ui_error( DWORD msg_id, DWORD type );
780
781 /* control event stuff */
782 extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
783                                       MSIRECORD *data);
784 extern VOID ControlEvent_CleanupDialogSubscriptions(MSIPACKAGE *package, LPWSTR dialog);
785 extern VOID ControlEvent_CleanupSubscriptions(MSIPACKAGE *package);
786 extern VOID ControlEvent_SubscribeToEvent(MSIPACKAGE *package, msi_dialog *dialog,
787                                       LPCWSTR event, LPCWSTR control, LPCWSTR attribute);
788 extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
789                                       LPCWSTR control, LPCWSTR attribute );
790
791 /* User Interface messages from the actions */
792 extern void ui_progress(MSIPACKAGE *, int, int, int, int);
793 extern void ui_actiondata(MSIPACKAGE *, LPCWSTR, MSIRECORD *);
794
795 /* string consts use a number of places  and defined in helpers.c*/
796 extern const WCHAR cszSourceDir[];
797 extern const WCHAR cszSOURCEDIR[];
798 extern const WCHAR szProductCode[];
799 extern const WCHAR cszRootDrive[];
800 extern const WCHAR cszbs[];
801
802 /* memory allocation macro functions */
803 static inline void *msi_alloc( size_t len )
804 {
805     return HeapAlloc( GetProcessHeap(), 0, len );
806 }
807
808 static inline void *msi_alloc_zero( size_t len )
809 {
810     return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
811 }
812
813 static inline void *msi_realloc( void *mem, size_t len )
814 {
815     return HeapReAlloc( GetProcessHeap(), 0, mem, len );
816 }
817
818 static inline void *msi_realloc_zero( void *mem, size_t len )
819 {
820     return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
821 }
822
823 static inline BOOL msi_free( void *mem )
824 {
825     return HeapFree( GetProcessHeap(), 0, mem );
826 }
827
828 inline static char *strdupWtoA( LPCWSTR str )
829 {
830     LPSTR ret = NULL;
831     DWORD len;
832
833     if (!str) return ret;
834     len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
835     ret = msi_alloc( len );
836     if (ret)
837         WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
838     return ret;
839 }
840
841 inline static LPWSTR strdupAtoW( LPCSTR str )
842 {
843     LPWSTR ret = NULL;
844     DWORD len;
845
846     if (!str) return ret;
847     len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
848     ret = msi_alloc( len * sizeof(WCHAR) );
849     if (ret)
850         MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
851     return ret;
852 }
853
854 inline static LPWSTR strdupW( LPCWSTR src )
855 {
856     LPWSTR dest;
857     if (!src) return NULL;
858     dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
859     if (dest)
860         lstrcpyW(dest, src);
861     return dest;
862 }
863
864 #endif /* __WINE_MSI_PRIVATE__ */