Extend the parser to deal with the CREATE TABLE query. The query
[wine] / dlls / msi / msipriv.h
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002 Mike McCormack for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_MSI_PRIVATE__
22 #define __WINE_MSI_PRIVATE__
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "msi.h"
29 #include "msiquery.h"
30 #include "objidl.h"
31
32 #define MSI_DATASIZEMASK 0x00ff
33 #define MSITYPE_VALID    0x0100
34 #define MSITYPE_STRING   0x0800
35 #define MSITYPE_NULLABLE 0x1000
36 #define MSITYPE_KEY      0x2000
37
38 struct tagMSITABLE;
39 typedef struct tagMSITABLE MSITABLE;
40
41 typedef struct pool_data_tag
42 {
43     USHORT *data;
44     UINT size;
45 } pool_data;
46
47 typedef struct string_data_tag
48 {
49     CHAR *data;
50     UINT size;
51 } string_data;
52
53 typedef struct string_table_tag
54 {
55     pool_data   pool;
56     string_data info;
57 } string_table;
58
59 typedef struct tagMSIDATABASE
60 {
61     IStorage *storage;
62     string_table strings;
63     LPWSTR mode;
64     MSITABLE *first_table, *last_table;
65 } MSIDATABASE;
66
67 struct tagMSIVIEW;
68
69 typedef struct tagMSIVIEWOPS
70 {
71     /*
72      * fetch_int - reads one integer from {row,col} in the table
73      *
74      *  This function should be called after the execute method.
75      *  Data returned by the function should not change until 
76      *   close or delete is called.
77      *  To get a string value, query the database's string table with
78      *   the integer value returned from this function.
79      */
80     UINT (*fetch_int)( struct tagMSIVIEW *, UINT row, UINT col, UINT *val );
81
82     /*
83      * execute - loads the underlying data into memory so it can be read
84      */
85     UINT (*execute)( struct tagMSIVIEW *, MSIHANDLE );
86
87     /*
88      * close - clears the data read by execute from memory
89      */
90     UINT (*close)( struct tagMSIVIEW * );
91
92     /*
93      * get_dimensions - returns the number of rows or columns in a table.
94      *
95      *  The number of rows can only be queried after the execute method
96      *   is called. The number of columns can be queried at any time.
97      */
98     UINT (*get_dimensions)( struct tagMSIVIEW *, UINT *rows, UINT *cols );
99
100     /*
101      * get_column_info - returns the name and type of a specific column
102      *
103      *  The name is HeapAlloc'ed by this function and should be freed by
104      *   the caller.
105      *  The column information can be queried at any time.
106      */
107     UINT (*get_column_info)( struct tagMSIVIEW *, UINT n, LPWSTR *name, UINT *type );
108
109     /*
110      * modify - not yet implemented properly
111      */
112     UINT (*modify)( struct tagMSIVIEW *, MSIMODIFY, MSIHANDLE );
113
114     /*
115      * delete - destroys the structure completely
116      */
117     UINT (*delete)( struct tagMSIVIEW * );
118
119 } MSIVIEWOPS;
120
121 typedef struct tagMSIVIEW
122 {
123     MSIVIEWOPS   *ops;
124 } MSIVIEW;
125
126 typedef struct tagMSISUMMARYINFO
127 {
128     IPropertyStorage *propstg;
129 } MSISUMMARYINFO;
130
131 typedef VOID (*msihandledestructor)( VOID * );
132
133 typedef struct tagMSIHANDLEINFO
134 {
135     UINT magic;
136     UINT type;
137     msihandledestructor destructor;
138     struct tagMSIHANDLEINFO *next;
139     struct tagMSIHANDLEINFO *prev;
140 } MSIHANDLEINFO;
141
142 #define MSIHANDLETYPE_ANY 0
143 #define MSIHANDLETYPE_DATABASE 1
144 #define MSIHANDLETYPE_SUMMARYINFO 2
145 #define MSIHANDLETYPE_VIEW 3
146 #define MSIHANDLETYPE_RECORD 4
147
148 #define MSI_MAJORVERSION 1
149 #define MSI_MINORVERSION 10
150 #define MSI_BUILDNUMBER 1029
151
152 #define GUID_SIZE 39
153
154 #define MSIHANDLE_MAGIC 0x4d434923
155 #define MSIMAXHANDLES 0x80
156
157 #define MSISUMINFO_OFFSET 0x30LL
158
159 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
160
161 MSIHANDLE alloc_msihandle(UINT type, UINT extra, msihandledestructor destroy);
162
163 /* add this table to the list of cached tables in the database */
164 extern void add_table(MSIDATABASE *db, MSITABLE *table);
165 extern void remove_table( MSIDATABASE *db, MSITABLE *table );
166 extern void free_table( MSIDATABASE *db, MSITABLE *table );
167 extern void free_cached_tables( MSIDATABASE *db );
168 extern UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table);
169 extern UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table);
170 extern UINT dump_string_table(MSIDATABASE *db);
171 extern UINT load_string_table( MSIDATABASE *db, string_table *pst);
172 extern UINT msi_id2string( string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
173 extern LPWSTR MSI_makestring( MSIDATABASE *db, UINT stringid);
174
175 UINT VIEW_find_column( MSIVIEW *view, LPWSTR name, UINT *n );
176
177 #endif /* __WINE_MSI_PRIVATE__ */