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