wined3d: Pass an IWineD3DBaseTextureImpl pointer to basetexture_get_lod().
[wine.git] / dlls / msi / create.c
blobc55390c8f7a6f2bc39f279286f878d373e21d58f
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002-2004 Mike McCormack for CodeWeavers
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.
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.
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
28 #include "msi.h"
29 #include "msiquery.h"
30 #include "objbase.h"
31 #include "objidl.h"
32 #include "msipriv.h"
33 #include "winnls.h"
35 #include "query.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
40 /* below is the query interface to a table */
42 typedef struct tagMSICREATEVIEW
44 MSIVIEW view;
45 MSIDATABASE *db;
46 LPCWSTR name;
47 BOOL bIsTemp;
48 BOOL hold;
49 column_info *col_info;
50 } MSICREATEVIEW;
52 static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
54 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
56 TRACE("%p %d %d %p\n", cv, row, col, val );
58 return ERROR_FUNCTION_FAILED;
61 static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
63 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
64 MSITABLE *table;
65 BOOL persist = (cv->bIsTemp) ? MSICONDITION_FALSE : MSICONDITION_TRUE;
67 TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name),
68 cv->bIsTemp?"temporary":"permanent");
70 if (cv->bIsTemp && !cv->hold)
71 return ERROR_SUCCESS;
73 return msi_create_table( cv->db, cv->name, cv->col_info, persist, &table);
76 static UINT CREATE_close( struct tagMSIVIEW *view )
78 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
80 TRACE("%p\n", cv);
82 return ERROR_SUCCESS;
85 static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
87 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
89 TRACE("%p %p %p\n", cv, rows, cols );
91 return ERROR_FUNCTION_FAILED;
94 static UINT CREATE_get_column_info( struct tagMSIVIEW *view,
95 UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
96 LPWSTR *table_name)
98 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
100 TRACE("%p %d %p %p %p %p\n", cv, n, name, type, temporary, table_name );
102 return ERROR_FUNCTION_FAILED;
105 static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
106 MSIRECORD *rec, UINT row)
108 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
110 TRACE("%p %d %p\n", cv, eModifyMode, rec );
112 return ERROR_FUNCTION_FAILED;
115 static UINT CREATE_delete( struct tagMSIVIEW *view )
117 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
119 TRACE("%p\n", cv );
121 msiobj_release( &cv->db->hdr );
122 msi_free( cv );
124 return ERROR_SUCCESS;
127 static const MSIVIEWOPS create_ops =
129 CREATE_fetch_int,
130 NULL,
131 NULL,
132 NULL,
133 NULL,
134 NULL,
135 CREATE_execute,
136 CREATE_close,
137 CREATE_get_dimensions,
138 CREATE_get_column_info,
139 CREATE_modify,
140 CREATE_delete,
141 NULL,
142 NULL,
143 NULL,
144 NULL,
145 NULL,
146 NULL,
147 NULL,
150 static UINT check_columns( const column_info *col_info )
152 const column_info *c1, *c2;
154 /* check for two columns with the same name */
155 for( c1 = col_info; c1; c1 = c1->next )
156 for( c2 = c1->next; c2; c2 = c2->next )
157 if (!strcmpW( c1->column, c2->column ))
158 return ERROR_BAD_QUERY_SYNTAX;
160 return ERROR_SUCCESS;
163 UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table,
164 column_info *col_info, BOOL hold )
166 MSICREATEVIEW *cv = NULL;
167 UINT r;
168 column_info *col;
169 BOOL temp = TRUE;
170 BOOL tempprim = FALSE;
172 TRACE("%p\n", cv );
174 r = check_columns( col_info );
175 if( r != ERROR_SUCCESS )
176 return r;
178 cv = msi_alloc_zero( sizeof *cv );
179 if( !cv )
180 return ERROR_FUNCTION_FAILED;
182 for( col = col_info; col; col = col->next )
184 if (!col->table)
185 col->table = table;
187 if( !col->temporary )
188 temp = FALSE;
189 else if ( col->type & MSITYPE_KEY )
190 tempprim = TRUE;
193 if ( !temp && tempprim )
195 msi_free( cv );
196 return ERROR_FUNCTION_FAILED;
199 /* fill the structure */
200 cv->view.ops = &create_ops;
201 msiobj_addref( &db->hdr );
202 cv->db = db;
203 cv->name = table;
204 cv->col_info = col_info;
205 cv->bIsTemp = temp;
206 cv->hold = hold;
207 *view = (MSIVIEW*) cv;
209 return ERROR_SUCCESS;