~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/msi/alter.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Implementation of the Microsoft Installer (msi.dll)
  3  *
  4  * Copyright 2006 Mike McCormack
  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include <stdarg.h>
 22 
 23 #include "windef.h"
 24 #include "winbase.h"
 25 #include "winerror.h"
 26 #include "wine/debug.h"
 27 #include "msi.h"
 28 #include "msiquery.h"
 29 #include "objbase.h"
 30 #include "objidl.h"
 31 #include "msipriv.h"
 32 
 33 #include "query.h"
 34 
 35 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
 36 
 37 typedef struct tagMSIALTERVIEW
 38 {
 39     MSIVIEW        view;
 40     MSIDATABASE   *db;
 41     MSIVIEW       *table;
 42     column_info   *colinfo;
 43     INT hold;
 44 } MSIALTERVIEW;
 45 
 46 static UINT ALTER_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
 47 {
 48     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
 49 
 50     TRACE("%p %d %d %p\n", av, row, col, val );
 51 
 52     return ERROR_FUNCTION_FAILED;
 53 }
 54 
 55 static UINT ALTER_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
 56 {
 57     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
 58 
 59     TRACE("%p %d %d %p\n", av, row, col, stm );
 60 
 61     return ERROR_FUNCTION_FAILED;
 62 }
 63 
 64 static UINT ALTER_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec )
 65 {
 66     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
 67 
 68     TRACE("%p %d %p\n", av, row, rec );
 69 
 70     return av->table->ops->get_row(av->table, row, rec);
 71 }
 72 
 73 static UINT ITERATE_columns(MSIRECORD *row, LPVOID param)
 74 {
 75     (*(UINT *)param)++;
 76     return ERROR_SUCCESS;
 77 }
 78 
 79 static BOOL check_column_exists(MSIDATABASE *db, LPCWSTR table, LPCWSTR column)
 80 {
 81     MSIQUERY *view;
 82     MSIRECORD *rec;
 83     UINT r;
 84 
 85     static const WCHAR query[] = {
 86         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
 87         '`','_','C','o','l','u','m','n','s','`',' ','W','H','E','R','E',' ',
 88         '`','T','a','b','l','e','`','=','\'','%','s','\'',' ','A','N','D',' ',
 89         '`','N','a','m','e','`','=','\'','%','s','\'',0
 90     };
 91 
 92     r = MSI_OpenQuery(db, &view, query, table, column);
 93     if (r != ERROR_SUCCESS)
 94         return FALSE;
 95 
 96     r = MSI_ViewExecute(view, NULL);
 97     if (r != ERROR_SUCCESS)
 98         goto done;
 99 
100     r = MSI_ViewFetch(view, &rec);
101     if (r == ERROR_SUCCESS)
102         msiobj_release(&rec->hdr);
103 
104 done:
105     msiobj_release(&view->hdr);
106     return (r == ERROR_SUCCESS);
107 }
108 
109 static UINT alter_add_column(MSIALTERVIEW *av)
110 {
111     UINT r, colnum = 1;
112     MSIQUERY *view;
113     MSIVIEW *columns;
114 
115     static const WCHAR szColumns[] = {'_','C','o','l','u','m','n','s',0};
116     static const WCHAR query[] = {
117         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
118         '`','_','C','o','l','u','m','n','s','`',' ','W','H','E','R','E',' ',
119         '`','T','a','b','l','e','`','=','\'','%','s','\'',' ','O','R','D','E','R',' ',
120         'B','Y',' ','`','N','u','m','b','e','r','`',0
121     };
122 
123     r = TABLE_CreateView(av->db, szColumns, &columns);
124     if (r != ERROR_SUCCESS)
125         return r;
126 
127     if (check_column_exists(av->db, av->colinfo->table, av->colinfo->column))
128         return ERROR_BAD_QUERY_SYNTAX;
129 
130     r = MSI_OpenQuery(av->db, &view, query, av->colinfo->table, av->colinfo->column);
131     if (r == ERROR_SUCCESS)
132     {
133         r = MSI_IterateRecords(view, NULL, ITERATE_columns, &colnum);
134         msiobj_release(&view->hdr);
135     }
136 
137     r = columns->ops->add_column(columns, av->colinfo->table,
138                                  colnum, av->colinfo->column,
139                                  av->colinfo->type, (av->hold == 1));
140 
141     columns->ops->delete(columns);
142     return r;
143 }
144 
145 static UINT ALTER_execute( struct tagMSIVIEW *view, MSIRECORD *record )
146 {
147     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
148     UINT ref;
149 
150     TRACE("%p %p\n", av, record);
151 
152     if (av->hold == 1)
153         av->table->ops->add_ref(av->table);
154     else if (av->hold == -1)
155     {
156         ref = av->table->ops->release(av->table);
157         if (ref == 0)
158             av->table = NULL;
159     }
160 
161     if (av->colinfo)
162         return alter_add_column(av);
163 
164     return ERROR_SUCCESS;
165 }
166 
167 static UINT ALTER_close( struct tagMSIVIEW *view )
168 {
169     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
170 
171     TRACE("%p\n", av );
172 
173     return ERROR_SUCCESS;
174 }
175 
176 static UINT ALTER_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
177 {
178     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
179 
180     TRACE("%p %p %p\n", av, rows, cols );
181 
182     return ERROR_FUNCTION_FAILED;
183 }
184 
185 static UINT ALTER_get_column_info( struct tagMSIVIEW *view,
186                 UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
187                 LPWSTR *table_name)
188 {
189     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
190 
191     TRACE("%p %d %p %p %p %p\n", av, n, name, type, temporary, table_name );
192 
193     return ERROR_FUNCTION_FAILED;
194 }
195 
196 static UINT ALTER_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
197                           MSIRECORD *rec, UINT row )
198 {
199     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
200 
201     TRACE("%p %d %p\n", av, eModifyMode, rec );
202 
203     return ERROR_FUNCTION_FAILED;
204 }
205 
206 static UINT ALTER_delete( struct tagMSIVIEW *view )
207 {
208     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
209 
210     TRACE("%p\n", av );
211     if (av->table)
212         av->table->ops->delete( av->table );
213     msi_free( av );
214 
215     return ERROR_SUCCESS;
216 }
217 
218 static UINT ALTER_find_matching_rows( struct tagMSIVIEW *view, UINT col,
219     UINT val, UINT *row, MSIITERHANDLE *handle )
220 {
221     TRACE("%p, %d, %u, %p\n", view, col, val, *handle);
222 
223     return ERROR_FUNCTION_FAILED;
224 }
225 
226 static const MSIVIEWOPS alter_ops =
227 {
228     ALTER_fetch_int,
229     ALTER_fetch_stream,
230     ALTER_get_row,
231     NULL,
232     NULL,
233     NULL,
234     ALTER_execute,
235     ALTER_close,
236     ALTER_get_dimensions,
237     ALTER_get_column_info,
238     ALTER_modify,
239     ALTER_delete,
240     ALTER_find_matching_rows,
241     NULL,
242     NULL,
243     NULL,
244     NULL,
245     NULL,
246     NULL,
247 };
248 
249 UINT ALTER_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_info *colinfo, int hold )
250 {
251     MSIALTERVIEW *av;
252     UINT r;
253 
254     TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
255 
256     av = msi_alloc_zero( sizeof *av );
257     if( !av )
258         return ERROR_FUNCTION_FAILED;
259 
260     r = TABLE_CreateView( db, name, &av->table );
261     if (r != ERROR_SUCCESS)
262     {
263         msi_free( av );
264         return r;
265     }
266 
267     if (colinfo)
268         colinfo->table = name;
269 
270     /* fill the structure */
271     av->view.ops = &alter_ops;
272     av->db = db;
273     av->hold = hold;
274     av->colinfo = colinfo;
275 
276     *view = &av->view;
277 
278     return ERROR_SUCCESS;
279 }
280 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.