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